# HG changeset patch # User Mark Doliner # Date 1151777095 0 # Node ID 47c3d00713afd2cf204e80b34e71439b6a0193dc # Parent 79f29d8dcd7aa92821d4b6b0ad63d85730614ff8 [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 diff -r 79f29d8dcd7a -r 47c3d00713af src/protocols/bonjour/jabber.c --- 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)