diff libgaim/connection.c @ 14752:4124030c3f3a

[gaim-migrate @ 17509] Fix the situation (I think it will only happen while shutting down) where GaimBuddy->proto_data could be accessed after it is freed. Specifically, it happened when gtkblist was requesting the emblems from the msn prpl. Big thanks to henningn for noticing the funkiness in valgrind. I discovered that there is no function to retrieve all the buddies for an account (shock, horror) - so I modified gaim_find_buddies() to return all the account buddies if "name" is NULL. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 18 Oct 2006 03:32:14 +0000
parents f23506e8f812
children 71404dbedabc
line wrap: on
line diff
--- a/libgaim/connection.c	Wed Oct 18 03:27:43 2006 +0000
+++ b/libgaim/connection.c	Wed Oct 18 03:32:14 2006 +0000
@@ -160,6 +160,7 @@
 gaim_connection_destroy(GaimConnection *gc)
 {
 	GaimAccount *account;
+	GSList *buddies, *tmp;
 #if 0
 	GList *wins;
 #endif
@@ -195,6 +196,14 @@
 			(prpl_info->close)(gc);
 	}
 
+	/* Clear out the proto data that was freed in the prpl close method*/
+	buddies = gaim_find_buddies(account, NULL);
+	for (tmp = buddies; tmp; tmp = tmp->next) {
+		GaimBuddy *buddy = tmp->data;
+		buddy->proto_data = NULL;
+	}
+	g_slist_free(buddies);
+
 	connections = g_list_remove(connections, gc);
 
 	gaim_connection_set_state(gc, GAIM_DISCONNECTED);