diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 4c229a72222..6c4b9458696 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -16,6 +16,7 @@ * XML::Node#{replace,add_previous_sibling,add_next_sibling} edge cases fixed related to libxml's text node merging. #308 * Fixed a segfault when GC occurs during xpath handler argument marshalling. #345 * Added hack to Slop decorator to work with previously defined methods. #330 + * Fix a memory leak when duplicating child nodes. #353 === 1.4.3 / 2010/07/28 diff --git a/ext/nokogiri/xml_node.c b/ext/nokogiri/xml_node.c index 782f84b3dbb..5fa8713f6ea 100644 --- a/ext/nokogiri/xml_node.c +++ b/ext/nokogiri/xml_node.c @@ -377,6 +377,8 @@ static VALUE duplicate_node(int argc, VALUE *argv, VALUE self) dup = xmlDocCopyNode(node, node->doc, (int)NUM2INT(level)); if(dup == NULL) return Qnil; + NOKOGIRI_ROOT_NODE(dup); + return Nokogiri_wrap_xml_node(rb_obj_class(self), dup); }