From: sgunderson@bigfoot.com <> Date: Wed, 21 Sep 2011 21:50:16 +0000 (+0200) Subject: Fix an attribute leak in the C++0x code. X-Git-Url: https://git.sesse.net/?p=xml-template;a=commitdiff_plain;h=620912444e16e4da049b124badd28acde29ce645 Fix an attribute leak in the C++0x code. --- diff --git a/c++0x/xml-template.cpp b/c++0x/xml-template.cpp index c2b62cd..e6e88a3 100644 --- a/c++0x/xml-template.cpp +++ b/c++0x/xml-template.cpp @@ -95,20 +95,17 @@ void Substitute::process(xmlNode *node, bool clean) if (child->type == XML_ELEMENT_NODE) { // Find the ID, if any. string id; + xmlAttr *id_attr = NULL; for (xmlAttr *attr = child->properties; attr != NULL; attr = attr->next) { if (strcmp(reinterpret_cast(attr->ns->href), "http://template.sesse.net/") == 0 && strcmp(reinterpret_cast(attr->name), "id") == 0) { id = reinterpret_cast(xmlNodeGetContent(attr->children)); - - if (clean) { - if (attr->prev == NULL) { - child->properties = attr->next; - } else { - attr->prev->next = attr->next; - } - } + id_attr = attr; } } + if (clean && id_attr != NULL) { + xmlRemoveProp(id_attr); + } // Check all substitutions to see if we found anything appropriate. for (auto it : substitution_map) {