# HG changeset patch # User Paul Aurich # Date 1269102009 0 # Node ID 40fee5f86bf830c47668eee99f497875873fe945 # Parent ffc1f997cb91909783b79f0045a6723b702c3cbf jabber: Proper memory management (and fix a segfault) and whitespace (Was freeing the nickname twice and not freeing the status codes at all) diff -r ffc1f997cb91 -r 40fee5f86bf8 libpurple/protocols/jabber/presence.c --- a/libpurple/protocols/jabber/presence.c Wed Mar 17 20:42:48 2010 +0000 +++ b/libpurple/protocols/jabber/presence.c Sat Mar 20 16:20:09 2010 +0000 @@ -670,7 +670,7 @@ if (chat->muc) { if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110))) is_our_resource = TRUE; - + if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(301))) { /* XXX: We got banned. YAY! (No GIR, that's bad) */ } @@ -744,15 +744,15 @@ g_free(reason); } - + if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(321))) { /* XXX: removed due to an affiliation change */ } - + if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(322))) { /* XXX: removed because room is now members-only */ } - + if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(332))) { /* XXX: removed due to system shutdown */ } @@ -996,7 +996,7 @@ JabberPresenceHandler *pih; if (child->type != XMLNODE_TYPE_TAG) continue; - + key = g_strdup_printf("%s %s", child->name, xmlnode_get_namespace(child)); pih = g_hash_table_lookup(presence_handlers, key); g_free(key); @@ -1052,11 +1052,15 @@ } out: + while (presence.chat_info.codes) + presence.chat_info.codes = + g_slist_delete_link(presence.chat_info.codes, + presence.chat_info.codes); + + g_free(presence.status); + g_free(presence.vcard_avatar_hash); g_free(presence.nickname); - g_free(presence.status); jabber_id_free(presence.jid_from); - g_free(presence.nickname); - g_free(presence.vcard_avatar_hash); } void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type)