Permalink
Browse files

Merge pull request #150 from SYSTRAN/clone_segfault

fix segfault for clone
  • Loading branch information...
2 parents 88a633c + 68ec745 commit 31fa8c4ef3321b5432f3b44557a40f6efe80475a @defunctzombie defunctzombie committed Jul 26, 2012
Showing with 12 additions and 1 deletion.
  1. +2 −1 src/xml_node.cc
  2. +10 −0 test/element.js
View
@@ -296,7 +296,8 @@ v8::Handle<v8::Value>
XmlNode::clone(bool recurse) {
v8::HandleScope scope;
- return scope.Close(XmlNode::New(xmlCopyNode(xml_obj, recurse)));
+ xmlNode* new_xml_obj = xmlDocCopyNode(xml_obj, xml_obj->doc, recurse);
+ return scope.Close(XmlNode::New(new_xml_obj));
}
v8::Handle<v8::Value>
View
@@ -137,3 +137,13 @@ module.exports.import = function(assert) {
assert.equal(child1, elem.childNodes()[0]); // child1 is the the first child of elem
assert.done();
};
+
+module.exports.clone = function(assert) {
+ var doc = libxml.Document();
+ var elem = doc.node('child');
+ var elem2 = elem.clone();
+ assert.equal(elem.name(), elem2.name());
+ assert.equal(elem.text(), elem2.text());
+ assert.equal(elem.toString(), elem2.toString());
+ assert.done();
+};

0 comments on commit 31fa8c4

Please sign in to comment.