pidgin: 3976bac9: If a buddy is deleted less than 11 secon...

nosnilmot at pidgin.im nosnilmot at pidgin.im
Tue Jan 5 20:05:30 EST 2010


-----------------------------------------------------------------
Revision: 3976bac9dc1aafa42217dda56118316cb2fed956
Ancestor: 0707f870a510922ae86ef379b5f01efa76d01402
Author: nosnilmot at pidgin.im
Date: 2010-01-06T00:55:08
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/3976bac9dc1aafa42217dda56118316cb2fed956

Modified files:
        pidgin/gtkconv.c

ChangeLog: 

If a buddy is deleted less than 11 seconds after they sign on or off, and
there is a conversation open with that buddy, the PurpleBuddy will be
dereferenced after it has been freed. This avoids that by duplicating the
required details from the PurpleBuddy for use in the status_timeout callback.

-------------- next part --------------
============================================================
--- pidgin/gtkconv.c	225ef256cf2eeade319d912d7cbfa990b2fa450d
+++ pidgin/gtkconv.c	4185d0c9653bbf92a803a9af494341287c7a6c5e
@@ -7624,16 +7624,24 @@ account_signing_off(PurpleConnection *gc
 	}
 }
 
+struct _status_timeout_user {
+	gchar *name;
+	PurpleAccount *account;
+};
+
 static gboolean
-update_buddy_status_timeout(PurpleBuddy *buddy)
+update_buddy_status_timeout(struct _status_timeout_user *user)
 {
 	/* To remove the signing-on/off door icon */
 	PurpleConversation *conv;
 
-	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, buddy->name, buddy->account);
+	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, user->name, user->account);
 	if (conv)
 		pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON);
 
+	g_free(user->name);
+	g_free(user);
+
 	return FALSE;
 }
 
@@ -7642,6 +7650,7 @@ update_buddy_status_changed(PurpleBuddy 
 {
 	PidginConversation *gtkconv;
 	PurpleConversation *conv;
+	struct _status_timeout_user *user;
 
 	gtkconv = get_gtkconv_with_contact(purple_buddy_get_contact(buddy));
 	if (gtkconv)
@@ -7654,8 +7663,12 @@ update_buddy_status_changed(PurpleBuddy 
 			pidgin_conv_update_fields(conv, PIDGIN_CONV_MENU);
 	}
 
+	user = g_malloc(sizeof(struct _status_timeout_user));
+	user->name = g_strdup(buddy->name);
+	user->account = buddy->account;
+
 	/* In case a conversation is started after the buddy has signed-on/off */
-	purple_timeout_add_seconds(11, (GSourceFunc)update_buddy_status_timeout, buddy);
+	purple_timeout_add_seconds(11, (GSourceFunc)update_buddy_status_timeout, user);
 }
 
 static void


More information about the Commits mailing list