tenderlove/nokogiri — Issue #550: add_next_sibling() on root node causes subsequent 
Author: duncan-bayne
Created: 2011-10-12 06:44:16+00:00
State: open

If I call add_next_sibling() on the root node of a document, it silently fails instead of raising an exception.

>> require 'nokogiri'
=> true
>> doc = Nokogiri::XML::Document.parse ''
=> #]>
>> foo = doc.xpath('//foo').first
=> #
>> bar = Nokogiri::XML::Node.new 'bar', doc
=> #
>> foo.parent.add_next_sibling bar
=> #
>> doc.to_s
=> "\n\n"

Interestingly, I broke our build by (accidentally) doing this.

The `add_next_sibling()` would succeed, but later (possibly during garbage collection?) I'd see segmentation faults at random places in the specs.

Removing the improper call to `add_next_sibling()` resolved the segmentation fault problem. Weird.