# HG changeset patch # User Paul Aurich # Date 1227298202 0 # Node ID c2438ad6e6c199d76dcc35cfeee2071959e53ab3 # Parent 27a9672371f1bfb25d46512f6b87010b58d98154 Error checking and use g_list_foreach diff -r 27a9672371f1 -r c2438ad6e6c1 libpurple/protocols/jabber/caps.c --- a/libpurple/protocols/jabber/caps.c Fri Nov 21 18:50:43 2008 +0000 +++ b/libpurple/protocols/jabber/caps.c Fri Nov 21 20:10:02 2008 +0000 @@ -154,8 +154,12 @@ 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 @@ 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 @@ 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 @@ 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);