# HG changeset patch # User Paul Aurich # Date 1241298539 0 # Node ID 54dcfe059dd4cea6c99a291d5e2a8117ee59f7cb # Parent 13d8b6c6ae42eaed28eeab34ea0b94beae6143e1 *** Plucked rev 3993504a (darkrain42@pidgin.im): Don't crash when a broken server sends us an occupant's presence with an empty resource. Closes #8361. diff -r 13d8b6c6ae42 -r 54dcfe059dd4 libpurple/protocols/jabber/presence.c --- a/libpurple/protocols/jabber/presence.c Fri May 01 16:05:55 2009 +0000 +++ b/libpurple/protocols/jabber/presence.c Sat May 02 21:08:59 2009 +0000 @@ -601,9 +601,11 @@ if(type && !strcmp(type, "unavailable")) { gboolean nick_change = FALSE; - /* If we haven't joined the chat yet, we don't care that someone - * left, or it was us leaving after we closed the chat */ - if (!chat->conv || chat->left) { + /* If the chat nick is invalid, we haven't yet joined, or we've + * already left (it was probably us leaving after we closed the + * chat), we don't care. + */ + if (!jid->resource || !chat->conv || chat->left) { if (chat->left && jid->resource && chat->handle && !strcmp(jid->resource, chat->handle)) jabber_chat_destroy(chat); @@ -664,6 +666,19 @@ } } } else { + /* + * XEP-0045 mandates the presence to include a resource (which is + * treated as the chat nick). Some non-compliant servers allow + * joining without a nick. + */ + if (!jid->resource) { + jabber_id_free(jid); + g_free(avatar_hash); + g_free(nickname); + g_free(status); + return; + } + if(!chat->conv) { chat->id = i++; chat->muc = muc;