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);
for (xmlAttr *attr = child->properties; attr != NULL; attr = attr->next) {
if (strcmp(reinterpret_cast<const char *>(attr->ns->href), "http://template.sesse.net/") == 0 &&
strcmp(reinterpret_cast<const char *>(attr->name), "id") == 0) {
- id = reinterpret_cast<const char *>(xmlNodeGetContent(attr->children));
+ xmlChar *id_buf = xmlNodeGetContent(attr->children);
+ id = reinterpret_cast<const char *>(id_buf);
+ xmlFree(id_buf);
id_attr = attr;
}
}