polotek/libxmljs — pull request #267 by skabbes (2014-10-21 06:38:07+00:00)
Title: Fix double free

Partially fixes: https://github.com/polotek/libxmljs/pull/163

After some exploration, it appears that `xmlFreeNode` actually recursively frees all children nodes. If those children nodes have ObjectWrap'd wrappers pointing to them, we then have dangling `xml_obj`'s. This PR addresses this by freeing those nodes only up to any nodes with `xml_obj->_private != NULL`. This effectively promotes those nodes to the be the new "owners" of their subtrees.

Although this fixes the ref_integrity tests isolation, it seems to expose some more bugs in test/attribute.js. I haven't been able to track those down yet.