From 42920e64cb3d6c9cdde2701b9fa41af1839e1522 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 19 Oct 2010 13:27:35 -0700 Subject: [PATCH] rooting nodes after duplication. fixes #353 --- CHANGELOG.rdoc | 1 + ext/nokogiri/xml_node.c | 2 ++ 2 files changed, 3 insertions(+) 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); }