# HG changeset patch # User Paul Aurich # Date 1241297650 0 # Node ID 0c1983abe991e1d9882f47534684b5870db52eaa # Parent 5c4a4a0f59297369cd298b75073fca3731870896 Don't crash when a broken server sends us an occupant's presence with an empty resource. Refs #8361. diff -r 5c4a4a0f5929 -r 0c1983abe991 libpurple/protocols/jabber/presence.c --- a/libpurple/protocols/jabber/presence.c Sat May 02 20:42:55 2009 +0000 +++ b/libpurple/protocols/jabber/presence.c Sat May 02 20:54:10 2009 +0000 @@ -666,9 +666,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); @@ -729,6 +731,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) { char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain); chat->id = i++;