gnucash maint: Bug 797481 - crash on close of unsaved tabs by pressing [X]
John Ralls
jralls at code.gnucash.org
Fri Nov 8 15:36:42 EST 2019
Updated via https://github.com/Gnucash/gnucash/commit/2bc7d314 (commit)
from https://github.com/Gnucash/gnucash/commit/32ff31fe (commit)
commit 2bc7d314ed6b08eacc35adfca8ac1ac64f8ec3a7
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Nov 8 12:33:00 2019 -0800
Bug 797481 - crash on close of unsaved tabs by pressing [X]
Pretty much the only place gnucash_sheet_get_block could crash is in
g_table_index, either because the GTable's GArray has been deleted or
the index is out of range. Add g_return_val_if_false tests for each
possibility.
diff --git a/gnucash/register/register-core/gtable.c b/gnucash/register/register-core/gtable.c
index 1c75fca05..b22ee6f18 100644
--- a/gnucash/register/register-core/gtable.c
+++ b/gnucash/register/register-core/gtable.c
@@ -83,7 +83,8 @@ g_table_destroy (GTable *gtable)
gpointer
g_table_index (GTable *gtable, int row, int col)
{
- guint index;
+ guint index = row * gtable->cols + col;
+ guint offset = index * gtable->entry_size;
if (gtable == NULL)
return NULL;
@@ -94,9 +95,9 @@ g_table_index (GTable *gtable, int row, int col)
if (col >= gtable->cols)
return NULL;
- index = ((row * gtable->cols) + col) * gtable->entry_size;
-
- return >able->array->data[index];
+ g_return_val_if_fail (gtable->array != NULL, NULL);
+ g_return_val_if_fail (gtable->array->len > index, NULL);
+ return >able->array->data[offset];
}
void
Summary of changes:
gnucash/register/register-core/gtable.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
More information about the gnucash-changes
mailing list