diff --git a/NEWS b/NEWS index d99b213b96b..8cbe2da10b0 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,9 @@ PHP NEWS - DBA: . Skip test if inifile is disabled. (orlitzky) +- DOM: + . Fixed bug GH-17145 (DOM memory leak). (nielsdos) + - FFI: . Fixed bug #79075 (FFI header parser chokes on comments). (nielsdos) diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index c8372ef8e17..9c1dc5f61d3 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 00000000000..7a10e5e5bb6 --- /dev/null +++ b/ext/dom/tests/gh17145.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-17145 (DOM memory leak) +--EXTENSIONS-- +dom +--CREDITS-- +YuanchengJiang +--SKIPIF-- + +--FILE-- +appendChild($element); +$element->setAttributeNodeNS($attr); +$attr->appendChild($doc->createEntityReference('amp')); +echo $attr->value; +?> +--EXPECT-- +n&