php / php-src

The PHP Interpreter
https://www.php.net
Other
38.17k stars 7.74k forks source link

Assertion failure in ext/dom/element.c #15910

Closed YuanchengJiang closed 1 month ago

YuanchengJiang commented 1 month ago

Description

The following code:

<?php
$doc = new DOMDocument();
$doc->appendChild($doc->createElement('container'));
var_dump($doc->documentElement->setAttributeNodeNS($doc)?->nodeValue);

Resulted in this output:

/php-src/ext/dom/element.c:696: dom_element_set_attribute_node_common: Assertion `attrp->type == XML_ATTRIBUTE_NODE' failed.
Aborted (core dumped)

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

cmb69 commented 1 month ago

https://github.com/php/php-src/blob/b438e2b1ed9b0f5a185a0385eef4d829005356a2/ext/dom/element.c#L686-L696

@nielsdos, the comment doesn't match the ZPP. Should ZPP be changed to dom_get_attr_ce(modern)?

nielsdos commented 1 month ago

Indeed, fixed.