Permalink
Browse files

fix leak of xmlNodes when not linked to a document

  • Loading branch information...
1 parent 7fdf7fc commit 4e3755cffbd2d7f571c04ff69dee6ea38761836e @triccardi-systran triccardi-systran committed Jul 18, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/xml_node.cc
View
7 src/xml_node.cc
@@ -195,9 +195,10 @@ XmlNode::~XmlNode() {
XmlDocument* doc = static_cast<XmlDocument*>(xml_obj->doc->_private);
doc->unref();
- // We do not free the xmlNode here. It could still be part of a document
- // It will be freed when the doc is freed
- // xmlFree(xml_obj);
+ // We do not free the xmlNode here if it is linked to a document
+ // It will be freed when the doc is freed
+ if (xml_obj->parent == NULL)
+ xmlFreeNode(xml_obj);
}
v8::Handle<v8::Value>

0 comments on commit 4e3755c

Please sign in to comment.