diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index c8372ef8e17ee..9c1dc5f61d391 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -2375,7 +2375,7 @@ void php_dom_get_content_into_zval(const xmlNode *nodep, zval *return_value, boo case XML_ATTRIBUTE_NODE: { bool free; xmlChar *value = php_libxml_attr_value((const xmlAttr *) nodep, &free); - RETURN_STRING_FAST((const char *) value); + RETVAL_STRING_FAST((const char *) value); if (free) { xmlFree(value); } diff --git a/ext/dom/tests/gh17145.phpt b/ext/dom/tests/gh17145.phpt new file mode 100644 index 0000000000000..34e4576788fbb --- /dev/null +++ b/ext/dom/tests/gh17145.phpt @@ -0,0 +1,18 @@ +--TEST-- +GH-17145 (DOM memory leak) +--EXTENSIONS-- +dom +--CREDITS-- +YuanchengJiang +--FILE-- +appendChild($element); +$element->setAttributeNodeNS($attr); +$attr->appendChild($doc->createEntityReference('amp')); +echo $attr->value; +?> +--EXPECT-- +n&