gnucash maint: Bug 732545 - gnucash-2.6.3 segfaults when started

John Ralls jralls at code.gnucash.org
Sun Sep 21 20:58:12 EDT 2014


Updated	 via  https://github.com/Gnucash/gnucash/commit/42013538 (commit)
	from  https://github.com/Gnucash/gnucash/commit/7e909d10 (commit)



commit 42013538dfe0a4d56996c108c0487fe181b162bc
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Sep 21 17:56:54 2014 -0700

    Bug 732545 - gnucash-2.6.3 segfaults when started
    
    Check all strings before calling g_strsplit.

diff --git a/src/gnome-utils/dialog-totd.c b/src/gnome-utils/dialog-totd.c
index 0d37335..99a4ebf 100644
--- a/src/gnome-utils/dialog-totd.c
+++ b/src/gnome-utils/dialog-totd.c
@@ -81,7 +81,7 @@ static void
 gnc_new_tip_number (TotdDialog *totd_dialog, gint offset)
 {
 
-    gchar **tip_components;
+    gchar **tip_components = NULL;
     gchar *tip;
 
     ENTER("TotdDialog %p, offset %d", totd_dialog, offset);
@@ -99,7 +99,8 @@ gnc_new_tip_number (TotdDialog *totd_dialog, gint offset)
      *
      *  Welcome to GnuCash version %s|2.4
      */
-    tip_components = g_strsplit(tip_list[current_tip_number], "|", 0);
+    if (tip_list[current_tip_number])
+	tip_components = g_strsplit(tip_list[current_tip_number], "|", 0);
     /* If the tip is empty, g_strisplit will return an empty list. This
      * shouldn't normally happen, but make sure we don't crash just in
      * case */
@@ -195,7 +196,8 @@ gnc_totd_initialize (void)
 
     /* Split into multiple strings. Due to the nature of the
      * tip list file, this can contain empty strings */
-    tip_list = g_strsplit(contents, "\n", 0);
+    if (contents)
+	tip_list = g_strsplit(contents, "\n", 0);
     g_free(contents);
     contents = NULL;
 
@@ -218,7 +220,8 @@ gnc_totd_initialize (void)
 
     /* Split cleaned up contents into multiple strings again */
     g_strfreev (tip_list);
-    tip_list = g_strsplit(contents, "\n", 0);
+    if (contents)
+        tip_list = g_strsplit(contents, "\n", 0);
 
     /* Convert any escaped characters while counting the strings */
     for (tip_count = 0; tip_list[tip_count] != NULL; tip_count++)



Summary of changes:
 src/gnome-utils/dialog-totd.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)



More information about the gnucash-changes mailing list