From: sgunderson@bigfoot.com <> Date: Wed, 21 Sep 2011 21:55:09 +0000 (+0200) Subject: Fix leak of the temporary clone root elements in the C++0x version. X-Git-Url: https://git.sesse.net/?p=xml-template;a=commitdiff_plain;h=8e1d37633979005acd694fc86ee91b724fe4361b Fix leak of the temporary clone root elements in the C++0x version. --- 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);