diff src/protocols/msn/slp.c @ 12126:35c4797c5c57

[gaim-migrate @ 14426] SF Patch #1359761, from sadrul "This patch plugs some memory leaks in a few places ragarding gaim_find_buddies. It also changes the call to gaim_find_buddy in a couple of places that only needs one buddy." I also fixed a case of g_free()ing a const char * in the sametime prpl. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Fri, 18 Nov 2005 12:05:40 +0000
parents a1aa681f1448
children fc464a0abccc
line wrap: on
line diff
--- a/src/protocols/msn/slp.c	Fri Nov 18 07:23:29 2005 +0000
+++ b/src/protocols/msn/slp.c	Fri Nov 18 12:05:40 2005 +0000
@@ -848,7 +848,6 @@
 {
 	GaimAccount *account;
 	GaimBuddy *buddy;
-	GSList *sl;
 	const char *old;
 	const char *new;
 
@@ -856,13 +855,10 @@
 
 	account = gaim_connection_get_account(gc);
 
-	sl = gaim_find_buddies(account, msn_object_get_creator(obj));
-
-	if (sl == NULL)
+	buddy = gaim_find_buddy(account, msn_object_get_creator(obj));
+	if (buddy == NULL)
 		return FALSE;
 
-	buddy = (GaimBuddy *)sl->data;
-
 	old = gaim_blist_node_get_string((GaimBlistNode *)buddy, "icon_checksum");
 	new = msn_object_get_sha1c(obj);
 
@@ -930,18 +926,19 @@
 	if (obj == NULL)
 	{
 		/* It seems the user has not set a msnobject */
-		GSList *sl;
+		GSList *sl, *list;
 
 		/* TODO: I think we need better buddy icon core functions. */
 		gaim_buddy_icons_set_for_user(account, user->passport, NULL, -1);
 
-		sl = gaim_find_buddies(account, user->passport);
+		list = gaim_find_buddies(account, user->passport);
 
-		for (; sl != NULL; sl = sl->next)
+		for (sl = list; sl != NULL; sl = sl->next)
 		{
 			GaimBuddy *buddy = (GaimBuddy *)sl->data;
 			gaim_blist_node_remove_setting((GaimBlistNode*)buddy, "icon_checksum");
 		}
+		g_slist_free(list);
 
 		return;
 	}
@@ -977,7 +974,7 @@
 	MsnUserList *userlist;
 	const char *info;
 	GaimAccount *account;
-	GSList *sl;
+	GSList *sl, *list;
 
 	g_return_if_fail(slpcall != NULL);
 
@@ -993,13 +990,14 @@
 	gaim_buddy_icons_set_for_user(account, slpcall->slplink->remote_user,
 								  (void *)data, size);
 
-	sl = gaim_find_buddies(account, slpcall->slplink->remote_user);
+	list = gaim_find_buddies(account, slpcall->slplink->remote_user);
 
-	for (; sl != NULL; sl = sl->next)
+	for (sl = list; sl != NULL; sl = sl->next)
 	{
 		GaimBuddy *buddy = (GaimBuddy *)sl->data;
 		gaim_blist_node_set_string((GaimBlistNode*)buddy, "icon_checksum", info);
 	}
+	g_slist_free(list);
 
 #if 0
 	/* Free one window slot */
@@ -1075,7 +1073,7 @@
 		gchar *data = NULL;
 		gsize len = 0;
 		const char *my_info = NULL;
-		GSList *sl;
+		GSList *sl, *list;
 
 #ifdef MSN_DEBUG_UD
 		gaim_debug_info("msn", "Requesting our own user display\n");
@@ -1096,13 +1094,14 @@
 		gaim_buddy_icons_set_for_user(account, user->passport, (void *)data, len);
 		g_free(data);
 
-		sl = gaim_find_buddies(account, user->passport);
+		list = gaim_find_buddies(account, user->passport);
 
-		for (; sl != NULL; sl = sl->next)
+		for (sl = list; sl != NULL; sl = sl->next)
 		{
 			GaimBuddy *buddy = (GaimBuddy *)sl->data;
 			gaim_blist_node_set_string((GaimBlistNode*)buddy, "icon_checksum", info);
 		}
+		g_slist_free(list);
 
 		/* Free one window slot */
 		session->userlist->buddy_icon_window++;