From 6ad2f394b3521c37f2d064d98b9cc1753378f485 Mon Sep 17 00:00:00 2001 From: "sgunderson@bigfoot.com" <> Date: Wed, 21 Sep 2011 23:43:09 +0200 Subject: [PATCH] Fix yet more memory leaks in the C++0x version. --- c++0x/xml-template.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/c++0x/xml-template.cpp b/c++0x/xml-template.cpp index a6a7316..f28b3dc 100644 --- a/c++0x/xml-template.cpp +++ b/c++0x/xml-template.cpp @@ -27,7 +27,7 @@ Replace::Replace(const string &str) : str(str) {} void Replace::process(xmlNode *node, bool clean) { - node->children = xmlNewTextLen(reinterpret_cast(str.data()), str.size()); + xmlNodeSetContentLen(node, reinterpret_cast(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); } -- 2.39.2