pidgin: 6fc45f1a: Buddy List needs to take a reference to ...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun May 31 16:50:28 EDT 2009


-----------------------------------------------------------------
Revision: 6fc45f1ad29b6531775d10e3d53ea239776b5ef6
Ancestor: 5c5977a6ed3591121ef82ff587586850b9dcd176
Author: darkrain42 at pidgin.im
Date: 2009-05-31T20:46:42
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6fc45f1ad29b6531775d10e3d53ea239776b5ef6

Modified files:
        pidgin/gtkblist.c pidgin/gtkprefs.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- pidgin/gtkblist.c	19f888cefb8b4b4b1e17d2545e0f13fa86cd36d6
+++ pidgin/gtkblist.c	122e9ad802a1125cad575c5cea42bed04d7416f1
@@ -5556,9 +5556,12 @@ static void pidgin_blist_show(PurpleBudd
 	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 @@ static void pidgin_blist_destroy(PurpleB
 	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,8 +7266,11 @@ pidgin_blist_set_theme(PidginBlistTheme 
 	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);
 
 	pidgin_blist_refresh(list);
============================================================
--- pidgin/gtkprefs.c	5d678a0da4f1c02fe5a6a738811ddd2db0ee0998
+++ pidgin/gtkprefs.c	612df25a2573ccf5c5ca8d706b9aef4075d3adb8
@@ -1163,14 +1163,15 @@ prefs_set_blist_theme_cb(GtkComboBox *co
 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);


More information about the Commits mailing list