Skip to content

Commit

Permalink
Merge branch 'master' of github.com:polotek/libxmljs
Browse files Browse the repository at this point in the history
  • Loading branch information
ncb000gt committed Jan 6, 2013
2 parents d4cbbc9 + f652298 commit fca49f1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/ref_integrity.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,3 +25,26 @@ module.exports.references = function(assert) {
assert.equal("child", nodes[1].name()); assert.equal("child", nodes[1].name());
assert.done(); 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.