Fix GH-15910: Assertion failure in ext/dom/element.c

This commit is contained in:
Niels Dossche 2024-09-16 20:06:07 +02:00
parent c65e042c0b
commit 55aa5f3ffb
No known key found for this signature in database
GPG Key ID: B8A8AD166DF0E2E5
3 changed files with 20 additions and 1 deletions

1
NEWS
View File

@ -5,6 +5,7 @@ PHP NEWS
- DOM:
. Fix XML serializer errata: xmlns="" serialization should be allowed.
(nielsdos)
. Fixed bug GH-15910 (Assertion failure in ext/dom/element.c). (nielsdos)
- MBString:
. Fixed bug GH-15824 (mb_detect_encoding(): Argument $encodings contains

View File

@ -683,7 +683,7 @@ static void dom_element_set_attribute_node_common(INTERNAL_FUNCTION_PARAMETERS,
dom_object *intern, *attrobj, *oldobj;
id = ZEND_THIS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &node, dom_get_node_ce(modern)) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &node, dom_get_attr_ce(modern)) == FAILURE) {
RETURN_THROWS();
}

View File

@ -0,0 +1,18 @@
--TEST--
GH-15910 (Assertion failure in ext/dom/element.c)
--EXTENSIONS--
dom
--CREDITS--
YuanchengJiang
--FILE--
<?php
$doc = new DOMDocument();
$doc->appendChild($doc->createElement('container'));
try {
$doc->documentElement->setAttributeNodeNS($doc);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
DOMElement::setAttributeNodeNS(): Argument #1 ($attr) must be of type DOMAttr, DOMDocument given