# HG changeset patch # User Mark Doliner # Date 1166167703 0 # Node ID c65def04fb4411e06111856e4206fe97b3aa9a12 # Parent 74511b8e9b4670100420f7a70f2cca28ee07ca5e [gaim-migrate @ 18005] Bug fix from Graham Booker. Fix an invalid pointer that resulted from removing the last attribute of an xmlnode. committer: Tailor Script diff -r 74511b8e9b46 -r c65def04fb44 libgaim/xmlnode.c --- a/libgaim/xmlnode.c Fri Dec 15 07:00:32 2006 +0000 +++ b/libgaim/xmlnode.c Fri Dec 15 07:28:23 2006 +0000 @@ -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; }