gnucash maint: Bug 798133 - Gnucash crash when any custom action is entered

John Ralls jralls at code.gnucash.org
Tue Apr 20 13:25:01 EDT 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/40e005d9 (commit)
	from  https://github.com/Gnucash/gnucash/commit/f7f35fae (commit)



commit 40e005d9630b3f317367ebb1193c06169050de5d
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Apr 20 10:22:05 2021 -0700

    Bug 798133 - Gnucash crash when any custom action is entered
    
    1. Protect strlen call in gnucash_sheet_modify_current_cell to
    prevent it from crashing.
    
    2. Handle NULL selection in gnc_item_list_key_event when key is
    GDK_KEY_Return so that new string in combo control is handled
    correctly.

diff --git a/gnucash/register/register-gnome/gnucash-item-list.c b/gnucash/register/register-gnome/gnucash-item-list.c
index 50d4d2ec0..c6543b20d 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.c
+++ b/gnucash/register/register-gnome/gnucash-item-list.c
@@ -352,6 +352,8 @@ gnc_item_list_key_event (GtkWidget* widget, GdkEventKey* event, gpointer data)
     {
     case GDK_KEY_Return:
         string = gnc_item_list_get_selection (item_list);
+        if (!string) // Nothing selected, might be new value
+             break;  // Let the sheet deal with it.
         g_signal_emit (G_OBJECT (item_list),
                        gnc_item_list_signals[ACTIVATE_ITEM],
                        0,
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 47fc82524..1cd995cda 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -888,7 +888,7 @@ gnucash_sheet_modify_current_cell (GnucashSheet *sheet, const gchar *new_text)
     GtkEditable *editable;
     Table *table = sheet->table;
     VirtualLocation virt_loc;
-    int new_text_len;
+    int new_text_len = 0;
     const char *retval;
     int cursor_position, start_sel, end_sel;
 
@@ -905,7 +905,8 @@ gnucash_sheet_modify_current_cell (GnucashSheet *sheet, const gchar *new_text)
     cursor_position = gtk_editable_get_position (editable);
     gtk_editable_get_selection_bounds (editable, &start_sel, &end_sel);
 
-    new_text_len = strlen (new_text);
+    if (new_text)
+         new_text_len = strlen (new_text);
 
     retval = gnc_table_modify_update (table, virt_loc,
                                       new_text, new_text_len,



Summary of changes:
 gnucash/register/register-gnome/gnucash-item-list.c | 2 ++
 gnucash/register/register-gnome/gnucash-sheet.c     | 5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)



More information about the gnucash-changes mailing list