From bea595d14391259bbabbac9285d612c19bed3a34 Mon Sep 17 00:00:00 2001 From: Milan Bouchet-Valat Date: Mon, 11 May 2009 20:52:33 +0200 Subject: [PATCH] Fix occasional crash in lists handling in ShellAppMonitor We need to reset the popularity GSList* at start, and everytime we load data about a another activity. This also implies fixing the typo about (activity != -1). Thanks to Dan Winship. http://bugzilla.gnome.org/show_bug.cgi?id=582215 --- src/shell-app-monitor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shell-app-monitor.c b/src/shell-app-monitor.c index 8269f5806..d9f487d75 100644 --- a/src/shell-app-monitor.c +++ b/src/shell-app-monitor.c @@ -889,7 +889,7 @@ static void restore_from_file (ShellAppMonitor *monitor) { int activity = -1; /* Means invalid ID */ - GSList *popularity; + GSList *popularity = NULL; AppPopularity *app_popularity; GFileInputStream *input; GDataInputStream *data_input; @@ -927,6 +927,7 @@ restore_from_file (ShellAppMonitor *monitor) popularity = g_slist_sort (popularity, popularity_sort_apps); g_hash_table_replace (monitor->popularities, GINT_TO_POINTER (activity), popularity); + popularity = NULL; } activity = atoi (line); /* FIXME: do something if conversion fails! */ @@ -942,7 +943,7 @@ restore_from_file (ShellAppMonitor *monitor) } /* Line is about an app. * If no activity was provided yet, just skip */ - else if ((activity != 1) && (strcmp (line, "") != 0)) + else if ((activity != -1) && (strcmp (line, "") != 0)) { info = g_strsplit (line, ",", 0); if (info[0] && info [1] && info[2]) /* Skip on wrong syntax */