mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 732545 - gnucash-2.6.3 segfaults when started
Check all strings before calling g_strsplit.
This commit is contained in:
parent
7e909d1008
commit
42013538df
@ -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++)
|
||||
|
Loading…
Reference in New Issue
Block a user