GNOME Bugzilla – Bug 109323
crash start gnome-sound-properties
Last modified: 2005-03-28 13:59:17 UTC
Description of Problem: Has updated a package control-center from version 2.2.0.1 up to 2.2.1. Then the program gnome-sound-properties falls at start. Having analysed distinctions and the debugging information has written small patch which has corrected this situation. Look please. Steps to reproduce the problem: 1. update to version 2.2.1 2. run gnome-sound-properties => krash 3. Actual Results: Expected Results: How often does this happen? Additional Information:
Created attachment 15227 [details] [review] patch
Created attachment 15228 [details] [review] prev to be patch.gz, this seample plain text
Thanks for the bug report
That patch leaks the values. It should look more like: if (!str_a) cmp = 1; else if (!str_b) cmp = -1; else cmp = g_ascii_strcasecmp (str_a, str_b); g_value_unset (&val_a); g_value_unset (&val_b); return cmp; } etc...
This is what the function looks like now. Does that mean this is wrong too? I mean, it's callung g_value_unset() earlier than what's in the comment above. static gint compare_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data) { GValue val_a = {0}; GValue val_b = {0}; gint cmp; const gchar *str_a, *str_b; gtk_tree_model_get_value (model, a, SORT_DATA_COLUMN, &val_a); str_a = g_value_get_string (&val_a); gtk_tree_model_get_value (model, b, SORT_DATA_COLUMN, &val_b); str_b = g_value_get_string (&val_b); cmp = g_ascii_strcasecmp (str_a, str_b); g_value_unset (&val_a); g_value_unset (&val_b); if (!str_a) return 1; else if (!str_b) return -1; else return cmp; }
Memory wise the new code looks ok. The main difference was the handling of NULL. g_ascii_strcasecmp will just g_warning on NULL if either arg is NULL. Which begs the question. Why are we checking NULL later ? The code is also a smidge bogus in that a=NULL b=NULL will claim that a > b Can a or b == NULL ?
any news on this ?