Skip to content

Commit

Permalink
Merge pull request #1006 from dbussink/fix_nokogiri_segfault_on_non_d…
Browse files Browse the repository at this point in the history
…ocument_nodes

Fix segfault when doing marking and doc is not a document node
  • Loading branch information
tenderlove committed Dec 9, 2013
2 parents 6697997 + 3fc79c0 commit c687b64
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ext/nokogiri/xml_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ static void debug_node_dealloc(xmlNodePtr x)

static void mark(xmlNodePtr node)
{
rb_gc_mark(DOC_RUBY_OBJECT(node->doc));
xmlNodePtr doc = node->doc;
if(doc->type == XML_DOCUMENT_NODE || doc->type == XML_HTML_DOCUMENT_NODE) {
if(DOC_RUBY_OBJECT_TEST(doc)) {
rb_gc_mark(DOC_RUBY_OBJECT(doc));
}
} else if(node->doc->_private) {
rb_gc_mark((VALUE)doc->_private);
}
}

/* :nodoc: */
Expand Down

0 comments on commit c687b64

Please sign in to comment.