cpw.darkrain42.xmpp.bosh: 97042580: Error checking and use g_list_foreach

paul at darkrain42.org paul at darkrain42.org
Sat Jan 17 23:56:40 EST 2009


-----------------------------------------------------------------
Revision: 9704258082ac3dfddd95b0ed6f02a796998b8c8a
Ancestor: a29a89266883d63fe4c43d0fd8e4ef149068fc41
Author: paul at darkrain42.org
Date: 2008-11-21T20:10:02
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/9704258082ac3dfddd95b0ed6f02a796998b8c8a

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

ChangeLog: 

Error checking and use g_list_foreach

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	6c49f6e2f44823d005418b0a61b8af53ba5b3aef
+++ libpurple/protocols/jabber/caps.c	63b19107b4e4d4e28e529de47e0a95fb15eac99c
@@ -154,8 +154,12 @@ static void jabber_caps_load(void) {
 					const char *type = xmlnode_get_attrib(child, "type");
 					const char *name = xmlnode_get_attrib(child, "name");
 					const char *lang = xmlnode_get_attrib(child, "lang");
-					
-					JabberIdentity *id = g_new0(JabberIdentity, 1);
+					JabberIdentity *id;
+
+					if (!category || !type)
+						continue;
+
+					id = g_new0(JabberIdentity, 1);
 					id->category = g_strdup(category);
 					id->type = g_strdup(type);
 					id->name = g_strdup(name);
@@ -321,13 +325,9 @@ void jabber_caps_free_clientinfo(JabberC
 		
 		clientinfo->identities = g_list_delete_link(clientinfo->identities,clientinfo->identities);
 	}
-	while(clientinfo->features) {
-		char *feat = clientinfo->features->data;
-		g_free(feat);
-		
-		clientinfo->features = g_list_delete_link(clientinfo->features,clientinfo->features);
-	}
-	
+
+	g_list_foreach(clientinfo->features, (GFunc)g_free, NULL);
+	g_list_free(clientinfo->features);
 	g_free(clientinfo);
 }
 
@@ -694,8 +694,12 @@ JabberCapsClientInfo *jabber_caps_parse_
 			const char *type = xmlnode_get_attrib(child, "type");
 			const char *name = xmlnode_get_attrib(child, "name");
 			const char *lang = xmlnode_get_attrib(child, "lang");
+			JabberIdentity *id;
 
-			JabberIdentity *id = g_new0(JabberIdentity, 1);
+			if (!category || !type)
+				continue;
+
+			id = g_new0(JabberIdentity, 1);
 			id->category = g_strdup(category);
 			id->type = g_strdup(type);
 			id->name = g_strdup(name);
@@ -709,7 +713,7 @@ JabberCapsClientInfo *jabber_caps_parse_
 				continue;
 			info->features = g_list_append(info->features, g_strdup(var));
 		} else if (!strcmp(child->name, "x")) {
-			if (!strcmp(child->xmlns, "jabber:x:data")) {
+			if (child->xmlns && !strcmp(child->xmlns, "jabber:x:data")) {
 				/* x-data form */
 				xmlnode *dataform = xmlnode_copy(child);
 				info->forms = g_list_append(info->forms, dataform);


More information about the Commits mailing list