]> git.sesse.net Git - xml-template/commitdiff
Fix yet more memory leaks in the C++0x version.
authorsgunderson@bigfoot.com <>
Wed, 21 Sep 2011 21:43:09 +0000 (23:43 +0200)
committersgunderson@bigfoot.com <>
Wed, 21 Sep 2011 21:43:09 +0000 (23:43 +0200)
c++0x/xml-template.cpp

index a6a7316846db452bdf03e364f9f81a830486aa72..f28b3dc93cd00e67fcefb0695576056330ae9a24 100644 (file)
@@ -27,7 +27,7 @@ Replace::Replace(const string &str)
        : str(str) {}
 
 void Replace::process(xmlNode *node, bool clean) {
-       node->children = xmlNewTextLen(reinterpret_cast<const xmlChar *>(str.data()), str.size());
+       xmlNodeSetContentLen(node, reinterpret_cast<const xmlChar *>(str.data()), str.size());
        if (clean) {
                clean_node(node);
        }
@@ -61,7 +61,10 @@ void Clone::process(xmlNode *node, bool clean)
                }
        }
 
-       node->children = NULL;
+       xmlFreeNodeList(node->children);
+       node->content = NULL;
+       node->children = node->last = NULL;
+
        for (auto child : new_nodes) {
                xmlAddChild(node, child);
        }