Mercurial > pidgin.yaz
changeset 27073:85a4c248f751
Buddy List needs to take a reference to the loaded theme. Fixes #8798.
Loading the preferences calls purple_theme_manager_refresh, which unrefs
the themes (and would free the loaded one), which leads to accessing freed
memory.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 31 May 2009 20:46:42 +0000 |
parents | 077eae6f3d84 |
children | a9f5afce8f39 |
files | pidgin/gtkblist.c pidgin/gtkprefs.c |
diffstat | 2 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkblist.c Sat May 30 00:58:04 2009 +0000 +++ b/pidgin/gtkblist.c Sun May 31 20:46:42 2009 +0000 @@ -5556,9 +5556,12 @@ gtkblist = PIDGIN_BLIST(list); priv = PIDGIN_BUDDY_LIST_GET_PRIVATE(gtkblist); + if (priv->current_theme) + g_object_unref(priv->current_theme); + theme_name = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/theme"); if (theme_name && *theme_name) - priv->current_theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(theme_name, "blist")); + priv->current_theme = g_object_ref(PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(theme_name, "blist"))); else priv->current_theme = NULL; @@ -6691,6 +6694,8 @@ gtkblist->arrow_cursor = NULL; priv = PIDGIN_BUDDY_LIST_GET_PRIVATE(gtkblist); + if (priv->current_theme) + g_object_unref(priv->current_theme); g_free(priv); g_free(gtkblist); @@ -7261,7 +7266,10 @@ else purple_prefs_set_string(PIDGIN_PREFS_ROOT "/blist/theme", ""); - priv->current_theme = theme; + if (priv->current_theme) + g_object_unref(priv->current_theme); + + priv->current_theme = theme ? g_object_ref(theme) : NULL; pidgin_blist_build_layout(list);
--- a/pidgin/gtkprefs.c Sat May 30 00:58:04 2009 +0000 +++ b/pidgin/gtkprefs.c Sun May 31 20:46:42 2009 +0000 @@ -1163,14 +1163,15 @@ static void prefs_set_blist_theme_cb(GtkComboBox *combo_box, gpointer user_data) { - PidginBlistTheme *theme; + PidginBlistTheme *theme = NULL; GtkTreeIter iter; gchar *name = NULL; g_return_if_fail(gtk_combo_box_get_active_iter(combo_box, &iter)); gtk_tree_model_get(GTK_TREE_MODEL(prefs_blist_themes), &iter, 2, &name, -1); - theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(name, "blist")); + if (name && *name) + theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(name, "blist")); g_free(name); pidgin_blist_set_theme(theme);