Bug 732545 - gnucash-2.6.3 segfaults when started

Check all strings before calling g_strsplit.
This commit is contained in:
John Ralls 2014-09-21 17:56:54 -07:00
parent 7e909d1008
commit 42013538df

View File

@ -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,6 +99,7 @@ gnc_new_tip_number (TotdDialog *totd_dialog, gint offset)
*
* Welcome to GnuCash version %s|2.4
*/
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
@ -195,6 +196,7 @@ gnc_totd_initialize (void)
/* Split into multiple strings. Due to the nature of the
* tip list file, this can contain empty strings */
if (contents)
tip_list = g_strsplit(contents, "\n", 0);
g_free(contents);
contents = NULL;
@ -218,6 +220,7 @@ gnc_totd_initialize (void)
/* Split cleaned up contents into multiple strings again */
g_strfreev (tip_list);
if (contents)
tip_list = g_strsplit(contents, "\n", 0);
/* Convert any escaped characters while counting the strings */