changeset 15922:d7feace39800

Fix some reads of invalid memory when shutting down bonjour when there are bonjour buddies in your buddy list. We were iterating through the blist and removing people as we go, which meant we were deleting bnode and then trying to access bnode->next
author Mark Doliner <mark@kingant.net>
date Sun, 25 Mar 2007 17:04:27 +0000
parents 6a5089fafd19
children 8bea220c0997
files libpurple/protocols/bonjour/bonjour.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/bonjour.c	Sun Mar 25 07:34:51 2007 +0000
+++ b/libpurple/protocols/bonjour/bonjour.c	Sun Mar 25 17:04:27 2007 +0000
@@ -58,7 +58,7 @@
 {
 	PurpleAccount *account = purple_connection_get_account(gc);
 	PurpleBuddyList *blist;
-	PurpleBlistNode *gnode, *cnode, *bnode;
+	PurpleBlistNode *gnode, *cnode, *cnodenext, *bnode, *bnodenext;
 	PurpleBuddy *buddy;
 
 	blist = purple_get_blist();
@@ -70,12 +70,14 @@
 	{
 		if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
 			continue;
-		for (cnode = gnode->child; cnode; cnode = cnode->next)
+		for (cnode = gnode->child; cnode; cnode = cnodenext)
 		{
+			cnodenext = cnode->next;
 			if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
 				continue;
-			for (bnode = cnode->child; bnode; bnode = bnode->next)
+			for (bnode = cnode->child; bnode; bnode = bnodenext)
 			{
+				bnodenext = bnode->next;
 				if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
 					continue;
 				buddy = (PurpleBuddy *)bnode;