pidgin: 46f6d47a: Make sure we free myspace buddy proto_da...

markdoliner at pidgin.im markdoliner at pidgin.im
Thu Feb 4 17:45:47 EST 2010


-----------------------------------------------------------------
Revision: 46f6d47a97be4bbe0262771c328eda1419d62542
Ancestor: 6df27c278b345c9fbd59166ceb4c562ce674d99f
Author: markdoliner at pidgin.im
Date: 2010-02-04T22:41:02
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/46f6d47a97be4bbe0262771c328eda1419d62542

Modified files:
        libpurple/protocols/myspace/myspace.c

ChangeLog: 

Make sure we free myspace buddy proto_data when we disconnect.  I believe
this fixes a memory leak and a crash when signing off while we're fetching
a buddy icon

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	ec7093319f8188f3a234ea37d53ee67ec7d214b5
+++ libpurple/protocols/myspace/myspace.c	24dfb0496390d036c339df25aa402469a76051b3
@@ -2264,6 +2264,13 @@ msim_login(PurpleAccount *acct)
 	}
 }
 
+static void
+msim_buddy_free(PurpleBuddy *buddy)
+{
+	msim_user_free(purple_buddy_get_protocol_data(buddy));
+	purple_buddy_set_protocol_data(buddy, NULL);
+}
+
 /**
  * Close the connection.
  *
@@ -2272,8 +2279,20 @@ msim_close(PurpleConnection *gc)
 static void
 msim_close(PurpleConnection *gc)
 {
+	GSList *buddies;
 	MsimSession *session;
 
+	/*
+	 * Free our protocol-specific buddy data.  It almost seems like libpurple
+	 * should call our buddy_free prpl callback so that we don't need to do
+	 * this... but it doesn't, so we do.
+	 */
+	buddies = purple_blist_get_buddies();
+	while (buddies != NULL) {
+		msim_buddy_free(buddies->data);
+		buddies = g_slist_delete_link(buddies, buddies);
+	}
+
 	if (gc == NULL) {
 		return;
 	}
@@ -2734,13 +2753,6 @@ msim_add_buddy(PurpleConnection *gc, Pur
 	msim_update_blocklist_for_buddy(session, name, TRUE, FALSE);
 }
 
-static void
-msim_buddy_free(PurpleBuddy *buddy)
-{
-	msim_user_free(purple_buddy_get_protocol_data(buddy));
-	purple_buddy_set_protocol_data(buddy, NULL);
-}
-
 /**
  * Remove a buddy from the user's buddy list.
  */


More information about the Commits mailing list