changeset 13900:47c3d00713af

[gaim-migrate @ 16386] sf patch #1497232, from Jono Cole, "Segfault in bonjour when another protocol is logged in" "The Bonjour protocol plugin was causing Gaim to segfault on receiving a message when other protocols were logged in. This is dependant on the active buddies in the buddy list and has been noticed the most when msn is used." committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 01 Jul 2006 18:04:55 +0000
parents 79f29d8dcd7a
children e40263ba9680
files src/protocols/bonjour/jabber.c
diffstat 1 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/bonjour/jabber.c	Sat Jul 01 15:20:58 2006 +0000
+++ b/src/protocols/bonjour/jabber.c	Sat Jul 01 18:04:55 2006 +0000
@@ -221,18 +221,29 @@
 struct _check_buddy_by_address_t {
 	char *address;
 	GaimBuddy **gb;
+	BonjourJabber *bj;
 };
 
 static void
 _check_buddy_by_address(gpointer key, gpointer value, gpointer data)
 {
 	GaimBuddy *gb = (GaimBuddy*)value;
-	BonjourBuddy *bb = (BonjourBuddy*)gb->proto_data;
-	struct _check_buddy_by_address_t *d = (struct _check_buddy_by_address_t *)data;
+	BonjourBuddy *bb;
+	struct _check_buddy_by_address_t *cbba;
+
+	gb = value;
+	cbba = data;
 
-	if (bb != NULL) {
-		if (g_strcasecmp(bb->ip, (char*)d->address) == 0)
-			*(d->gb) = gb;
+	/*
+	 * If the current GaimBuddy's data is not null and the GaimBuddy's account
+	 * is the same as the account requesting the check then continue to determine
+	 * whether the buddies IP matches the target IP.
+	 */
+	if (cbba->bj->account == gb->account)
+	{
+		bb = gb->proto_data;
+		if ((bb != NULL) && (g_strcasecmp(bb->ip, cbba->address) == 0))
+			*(cbba->gb) = gb;
 	}
 }
 
@@ -371,6 +382,7 @@
 	socklen_t sin_size = sizeof(struct sockaddr);
 	int client_socket;
 	BonjourBuddy *bb = NULL;
+	BonjourJabber *bj = data;
 	char *address_text = NULL;
 	GaimBuddyList *bl = gaim_get_blist();
 	struct _check_buddy_by_address_t *cbba;
@@ -386,11 +398,12 @@
 	}
 	fcntl(client_socket, F_SETFL, O_NONBLOCK);
 
-	/* Look for the buddy that has open the conversation and fill information */
+	/* Look for the buddy that has opened the conversation and fill information */
 	address_text = inet_ntoa(their_addr.sin_addr);
 	cbba = g_new0(struct _check_buddy_by_address_t, 1);
 	cbba->address = address_text;
 	cbba->gb = &gb;
+	cbba->bj = bj;
 	g_hash_table_foreach(bl->buddies, _check_buddy_by_address, cbba);
 	g_free(cbba);
 	if (gb == NULL)