X-Git-Url: https://git.sesse.net/?p=xml-template;a=blobdiff_plain;f=c%2B%2B0x%2Fxml-template.cpp;h=96f027033ba30acf87ca50af3c6a22a49ed03ef8;hp=067bf730b6cfa0b2f4af94f64258dd809caee212;hb=8e1d37633979005acd694fc86ee91b724fe4361b;hpb=47a96d1f08578ba143b50a7e83c0338dcebcacc6 diff --git a/c++0x/xml-template.cpp b/c++0x/xml-template.cpp index 067bf73..96f0270 100644 --- a/c++0x/xml-template.cpp +++ b/c++0x/xml-template.cpp @@ -57,9 +57,12 @@ void Clone::process(xmlNode *node, bool clean) xmlNode *new_node; xmlDOMWrapCloneNode(NULL, node->doc, node, &new_node, node->doc, NULL, 1, 0); it->process(new_node, clean); - for (xmlNode *child = new_node->children; child != NULL; child = child->next) { + while (new_node->children != NULL) { + xmlNode *child = new_node->children; + xmlUnlinkNode(child); new_nodes.push_back(child); } + xmlFreeNode(new_node); } xmlFreeNodeList(node->children);