changeset 29623:40fee5f86bf8

jabber: Proper memory management (and fix a segfault) and whitespace (Was freeing the nickname twice and not freeing the status codes at all)
author Paul Aurich <paul@darkrain42.org>
date Sat, 20 Mar 2010 16:20:09 +0000
parents ffc1f997cb91
children eb72ae3357dc
files libpurple/protocols/jabber/presence.c
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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)