pidgin.2.5.6: b61d4041: Fix the crash/leaks in statusbox
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Wed May 6 15:00:26 EDT 2009
-----------------------------------------------------------------
Revision: b61d4041b364e1dc67590000472f86f9c92717d3
Ancestor: 49a2a494d7a54a9edff3f1f45070e481c63d1697
Author: darkrain42 at pidgin.im
Date: 2009-05-06T18:58:47
Branch: im.pidgin.pidgin.2.5.6
URL: http://d.pidgin.im/viewmtn/revision/info/b61d4041b364e1dc67590000472f86f9c92717d3
Modified files:
libpurple/buddyicon.c libpurple/protocols/null/nullprpl.c
pidgin/gtkstatusbox.c
ChangeLog:
Fix the crash/leaks in statusbox
*** Plucked rev 0cb6e54b (darkrain42 at pidgin.im):
Look up the old image before we store the new one in the hash table.
Looking up the new image and then unref:ing it (hence freeing the data
and subsequently returning it) is not good. This was causing problems
with changing buddy icons while using mystatusbox. Refs #9120.
*** Plucked rev d25c9ed7 (darkrain42 at pidgin.im):
Don't leak image refs in gtkstatusbox and assertion failure in nullprpl
purple_imgstore_new_from_file gives us a ref and
pidgin_status_box_set_buddy_icon also takes a ref.
-------------- next part --------------
============================================================
--- libpurple/buddyicon.c a67d2a27063f810d014699d3be6328906f68f3f3
+++ libpurple/buddyicon.c e043eb7385ac9e9b3c789408ae9ed3520df82d65
@@ -753,6 +753,8 @@ purple_buddy_icons_set_account_icon(Purp
}
unref_filename(old_icon);
+ old_img = g_hash_table_lookup(pointer_icon_cache, account);
+
if (img)
g_hash_table_insert(pointer_icon_cache, account, img);
else
@@ -770,7 +772,7 @@ purple_buddy_icons_set_account_icon(Purp
prpl_info->set_buddy_icon(gc, img);
}
- if ((old_img = g_hash_table_lookup(pointer_icon_cache, account)))
+ if (old_img)
purple_imgstore_unref(old_img);
else if (old_icon)
{
============================================================
--- libpurple/protocols/null/nullprpl.c 9d14dffe44270ac50efbdbc633fe275ce510c13a
+++ libpurple/protocols/null/nullprpl.c a8dea54335bd297d423142f372bfe01a398e9a8e
@@ -927,7 +927,8 @@ static void nullprpl_set_buddy_icon(Purp
static void nullprpl_set_buddy_icon(PurpleConnection *gc,
PurpleStoredImage *img) {
purple_debug_info("nullprpl", "setting %s's buddy icon to %s\n",
- gc->account->username, purple_imgstore_get_filename(img));
+ gc->account->username,
+ img ? purple_imgstore_get_filename(img) : "(null)");
}
static void nullprpl_remove_group(PurpleConnection *gc, PurpleGroup *group) {
============================================================
--- pidgin/gtkstatusbox.c 156fbde8516ee4c75d1b6493adcbe95b3f4ed03f
+++ pidgin/gtkstatusbox.c ed21471a217e11984be939f4709bb4a0998cc333
@@ -417,16 +417,15 @@ setup_icon_box(PidginStatusBox *status_b
PurpleStoredImage *img = NULL;
if (filename != NULL)
- {
- gchar *contents;
- gsize size;
- if (g_file_get_contents(filename, &contents, &size, NULL))
- {
- img = purple_imgstore_add(contents, size, filename);
- }
- }
+ img = purple_imgstore_new_from_file(filename);
pidgin_status_box_set_buddy_icon(status_box, img);
+ if (img)
+ /*
+ * purple_imgstore_new gives us a reference and
+ * pidgin_status_box_set_buddy_icon also takes one.
+ */
+ purple_imgstore_unref(img);
}
status_box->hand_cursor = gdk_cursor_new (GDK_HAND2);
@@ -1496,6 +1495,13 @@ buddy_icon_set_cb(const char *filename,
if (filename)
data = pidgin_convert_buddy_icon(plug, filename, &len);
img = purple_buddy_icons_set_account_icon(box->account, data, len);
+ if (img)
+ /*
+ * set_account_icon doesn't give us a reference, but we
+ * unref one below (for the other code path)
+ */
+ purple_imgstore_ref(img);
+
purple_account_set_buddy_icon_path(box->account, filename);
purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL));
@@ -1515,7 +1521,7 @@ buddy_icon_set_cb(const char *filename,
size_t len = 0;
if (filename)
data = pidgin_convert_buddy_icon(plug, filename, &len);
- img = purple_buddy_icons_set_account_icon(account, data, len);
+ purple_buddy_icons_set_account_icon(account, data, len);
purple_account_set_buddy_icon_path(account, filename);
}
}
@@ -1523,17 +1529,12 @@ buddy_icon_set_cb(const char *filename,
/* Even if no accounts were processed, load the icon that was set. */
if (filename != NULL)
- {
- gchar *contents;
- gsize size;
- if (g_file_get_contents(filename, &contents, &size, NULL))
- {
- img = purple_imgstore_add(contents, size, filename);
- }
- }
+ img = purple_imgstore_new_from_file(filename);
}
pidgin_status_box_set_buddy_icon(box, img);
+ if (img)
+ purple_imgstore_unref(img);
}
static void
More information about the Commits
mailing list