diff --git a/Zend/tests/gh21504.inc b/Zend/tests/gh21504.inc new file mode 100644 index 0000000000000..71dc5c2e61f64 --- /dev/null +++ b/Zend/tests/gh21504.inc @@ -0,0 +1,3 @@ + var_dump(...); diff --git a/Zend/tests/gh21504.phpt b/Zend/tests/gh21504.phpt new file mode 100644 index 0000000000000..5fd9eaff91ab6 --- /dev/null +++ b/Zend/tests/gh21504.phpt @@ -0,0 +1,12 @@ +--TEST-- +GH-21504: Incorrect RC-handling for ZEND_EXT_STMT op1 +--FILE-- + +--EXPECT-- +string(4) "1234" diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ee83ee75ff6ea..ab6f2fb1e98fc 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1950,6 +1950,9 @@ static void zend_do_extended_stmt(znode* result) /* {{{ */ opline->opcode = ZEND_EXT_STMT; if (result) { + if (result->op_type == IS_CONST) { + Z_TRY_ADDREF(result->u.constant); + } SET_NODE(opline->op1, result); } } diff --git a/ext/dom/node.c b/ext/dom/node.c index 19b6c2eeae3b9..7ff5c6615a6ca 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -2132,7 +2132,7 @@ static void dom_relink_ns_decls_element(HashTable *links, xmlNodePtr node) ns->_private = attr; if (attr->prev) { - attr->prev = attr->next; + attr->prev->next = attr->next; } else { node->properties = attr->next; } diff --git a/ext/dom/tests/modern/xml/gh21548.phpt b/ext/dom/tests/modern/xml/gh21548.phpt new file mode 100644 index 0000000000000..55299c8d6e679 --- /dev/null +++ b/ext/dom/tests/modern/xml/gh21548.phpt @@ -0,0 +1,17 @@ +--TEST-- +GH-21548 (Dom\XMLDocument::C14N() emits duplicate xmlns declarations after setAttributeNS()) +--CREDITS-- +Toon Verwerft (veewee) +--EXTENSIONS-- +dom +--FILE-- +'); +$doc->documentElement->setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:ns1", "urn:a"); + +echo $doc->C14N() . PHP_EOL; + +?> +--EXPECT-- +