Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Clone segfault #150

Merged
merged 2 commits into from

3 participants

@triccardi-systran

xmlCopyNode sets doc to NULL on all created xmlNode.

Then XmlNode::XmlNode reads doc->_private: segfault.

With xmlDocCopyNode the doc is set.

@travisbot

This pull request passes (merged 68ec745 into f4707b5).

@defunctzombie defunctzombie merged commit 31fa8c4 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2012
  1. @triccardi-systran

    unit test: clone

    triccardi-systran authored
  2. @triccardi-systran

    fix clone method: set doc on nodes to avoid a segfault when XmlNode::…

    triccardi-systran authored
    …XmlNode reads xml_obj->doc->_private
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 1 deletion.
  1. +2 −1  src/xml_node.cc
  2. +10 −0 test/element.js
View
3  src/xml_node.cc
@@ -295,7 +295,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
10 test/element.js
@@ -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();
+};
Something went wrong with that request. Please try again.