pidgin: a758341d: jabber: Proper memory management (and fi...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sat Mar 20 12:25:39 EDT 2010


-----------------------------------------------------------------
Revision: a758341daab23fe08b983dd3e00c8db27e225d59
Ancestor: 6fbd38d2c19152635e0bd90f861c4c7e5315c4bb
Author: darkrain42 at pidgin.im
Date: 2010-03-20T16:20:09
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a758341daab23fe08b983dd3e00c8db27e225d59

Modified files:
        libpurple/protocols/jabber/presence.c

ChangeLog: 

jabber: Proper memory management (and fix a segfault) and whitespace

(Was freeing the nickname twice and not freeing the status codes at all)

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/presence.c	36c2a518f003ade30488db71d7354e5d108b4683
+++ libpurple/protocols/jabber/presence.c	8f81647bea936b11f5476031525719d9d3417e18
@@ -670,7 +670,7 @@ handle_presence_chat(JabberStream *js, J
 		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 @@ handle_presence_chat(JabberStream *js, J
 
 				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 @@ void jabber_presence_parse(JabberStream 
 		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:
 	}
 
 out:
-	g_free(presence.nickname);
+	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);
-	jabber_id_free(presence.jid_from);
+	g_free(presence.vcard_avatar_hash);
 	g_free(presence.nickname);
-	g_free(presence.vcard_avatar_hash);
+	jabber_id_free(presence.jid_from);
 }
 
 void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type)


More information about the Commits mailing list