]> git.sesse.net Git - xml-template/commitdiff
Fix the last memory leaks from the clone test.
authorsgunderson@bigfoot.com <>
Wed, 21 Sep 2011 22:00:14 +0000 (00:00 +0200)
committersgunderson@bigfoot.com <>
Wed, 21 Sep 2011 22:00:14 +0000 (00:00 +0200)
c++0x/xml-template.cpp

index 96f027033ba30acf87ca50af3c6a22a49ed03ef8..c1d43edb421bada23f539026b60f60577d6f5124 100644 (file)
@@ -17,6 +17,9 @@ void clean_node(xmlNode *node)
                xmlReplaceNode(node, frag);
                frag->children = node->children;
                frag->last = node->last;
+
+               node->children = node->last = NULL;
+               xmlFreeNode(node);
        }
 }
 
@@ -92,7 +95,9 @@ Substitute::~Substitute()
 
 void Substitute::process(xmlNode *node, bool clean)
 {
-       for (xmlNode *child = node->children; child != NULL; child = child->next) {
+       xmlNode *next_child;
+       for (xmlNode *child = node->children; child != NULL; child = next_child) {
+               next_child = child->next;       
                bool processed = false;
 
                if (child->type == XML_ELEMENT_NODE) {
@@ -122,7 +127,7 @@ void Substitute::process(xmlNode *node, bool clean)
                                }
                        }
                }
-               
+
                if (!processed) {
                        process(child, clean);
                }