libxml-raku / LibXML-raku

Raku bindings to the libxml2 native library
Artistic License 2.0
11 stars 5 forks source link

Document level removeChildnodes segfault #56

Closed dwarring closed 3 years ago

dwarring commented 3 years ago

This is segfaulting:

use LibXML::Document;
for 1..1000 {
    my LibXML::Document $doc .= parse: :file('example/dtd.xml');
    $doc.removeChildNodes;
}
dwarring commented 3 years ago

If I change <doc>This is a valid document &foo; !</doc> to <doc>This is a valid document !</doc>, it no longer seg-faults.

It's the entity reference, which gets included in the returned document fragment, but has, a now invalid, reference back to the DtD.

dwarring commented 3 years ago

Fixed by avoiding following entity references in GC, Dereferencing Entity References is still dangerous, if the DtD has been removed.

dwarring commented 3 years ago

Entity reference content is now removed when the Dtd is removed.