From: <the...@us...> - 2006-12-15 07:28:23
|
Revision: 18005 http://svn.sourceforge.net/gaim/?rev=18005&view=rev Author: thekingant Date: 2006-12-14 23:28:23 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Bug fix from Graham Booker. Fix an invalid pointer that resulted from removing the last attribute of an xmlnode. Modified Paths: -------------- trunk/libgaim/xmlnode.c Modified: trunk/libgaim/xmlnode.c =================================================================== --- trunk/libgaim/xmlnode.c 2006-12-15 07:00:32 UTC (rev 18004) +++ trunk/libgaim/xmlnode.c 2006-12-15 07:28:23 UTC (rev 18005) @@ -127,14 +127,16 @@ for(attr_node = node->child; attr_node; attr_node = attr_node->next) { if(attr_node->type == XMLNODE_TYPE_ATTRIB && - !strcmp(attr_node->name, attr)) { + !strcmp(attr_node->name, attr)) + { if(node->child == attr_node) { node->child = attr_node->next; - } else if (node->lastchild == attr_node) { - node->lastchild = sibling; } else { sibling->next = attr_node->next; } + if (node->lastchild == attr_node) { + node->lastchild = sibling; + } xmlnode_free(attr_node); return; } @@ -155,14 +157,16 @@ { if(attr_node->type == XMLNODE_TYPE_ATTRIB && !strcmp(attr_node->name, attr) && - !strcmp(attr_node->xmlns, xmlns)) { + !strcmp(attr_node->xmlns, xmlns)) + { if(node->child == attr_node) { node->child = attr_node->next; - } else if (node->lastchild == attr_node) { - node->lastchild = sibling; } else { sibling->next = attr_node->next; } + if (node->lastchild == attr_node) { + node->lastchild = sibling; + } xmlnode_free(attr_node); return; } @@ -204,7 +208,7 @@ attrib_node->data = g_strdup(value); attrib_node->xmlns = g_strdup(xmlns); - xmlnode_insert_child(node, attrib_node); + xmlnode_insert_child(node, attrib_node); } const char * @@ -231,13 +235,13 @@ g_return_val_if_fail(node != NULL, NULL); for(x = node->child; x; x = x->next) { - if(x->type == XMLNODE_TYPE_ATTRIB && + if(x->type == XMLNODE_TYPE_ATTRIB && !strcmp(attr, x->name) && !strcmp(x->xmlns, xmlns)) { return x->data; } } - return NULL; + return NULL; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |