Permalink
Browse files

Merge branch 'master' of github.com:polotek/libxmljs

  • Loading branch information...
2 parents d4cbbc9 + f652298 commit fca49f121b77ee43dff850f9436ba452506f621f @ncb000gt ncb000gt committed Jan 6, 2013
Showing with 23 additions and 0 deletions.
  1. +23 −0 test/ref_integrity.js
View
@@ -25,3 +25,26 @@ module.exports.references = function(assert) {
assert.equal("child", nodes[1].name());
assert.done();
};
+
+// test that double-freeing XmlNode's doesn't cause a segfault
+module.exports.double_free = function(assert) {
+ var children = null;
+
+ // stick this portion of code into a self-executing function so
+ // its internal variables can be garbage collected
+ (function(){
+ var html = '<html><body><div><span></span></div></body></html>';
+ var doc = libxml.parseHtml(html);
+
+ doc.find('//div').forEach(function(tag){
+ // provide a reference to childNodes so they are exposed as XmlNodes
+ // and therefore subject to V8's garbage collection
+ children = tag.childNodes();
+ tag.remove();
+ });
+ })();
+
+ global.gc();
+ assert.ok(children[0].attrs());
+ assert.done();
+};

0 comments on commit fca49f1

Please sign in to comment.