Skip to content

Assertion failure in ext/dom/parentnode/tree.c #16151

Closed

Description

@chibinz

Description

The following code:

<?php

$comment = new DOMComment ( "h" );
$element = new DOMElement ( "N" , "W" , "y" );
$attr = new DOMAttr ( "c" , "n" );
$doc = new DOMDocument (  );
$doc -> adoptNode ( $element );
$element -> setAttributeNodeNS ( $attr );
$attr -> insertBefore ( $comment );
$comment -> replaceWith ( "Q" );

Resulted in this output:

php: /tmp/php-afl/ext/dom/parentnode/tree.c:243: _Bool dom_is_pre_insert_valid_without_step_1(php_libxml_ref_obj *, xmlNodePtr, xmlNodePtr, xmlNodePtr, xmlDocPtr): Assertion `!php_dom_pre_insert_is_parent_invalid(parentNode)' failed.

But I expected this output instead:

no crash

PHP Version

PHP 8.4.0-dev

Operating System

No response

Activity

  1. ndossche commented on Oct 1, 2024

    @ndossche
    Member

    Problem is that the constraints of the DOM tree are broken because a comment is inserted as a child of an attribute, this should not be possible. This is because the old DOM doesn't follow spec, bleh

  2. added a commit that references this issue on Oct 1, 2024
    81dc493
  3. added 4 commits that reference this issue on Oct 1, 2024
    cd67c09
    341c26f
    f1b41d7
    066d18f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions