From 42013538dfe0a4d56996c108c0487fe181b162bc Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 21 Sep 2014 17:56:54 -0700 Subject: [PATCH] Bug 732545 - gnucash-2.6.3 segfaults when started Check all strings before calling g_strsplit. --- src/gnome-utils/dialog-totd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gnome-utils/dialog-totd.c b/src/gnome-utils/dialog-totd.c index 0d373353af..99a4ebfec0 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++)