Skip to content

Commit c015242

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-17145: DOM memory leak
2 parents bb6dbdc + 4656c22 commit c015242

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

ext/dom/php_dom.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ void php_dom_get_content_into_zval(const xmlNode *nodep, zval *return_value, boo
23712371
case XML_ATTRIBUTE_NODE: {
23722372
bool free;
23732373
xmlChar *value = php_libxml_attr_value((const xmlAttr *) nodep, &free);
2374-
RETURN_STRING_FAST((const char *) value);
2374+
RETVAL_STRING_FAST((const char *) value);
23752375
if (free) {
23762376
xmlFree(value);
23772377
}

ext/dom/tests/gh17145.phpt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-17145 (DOM memory leak)
3+
--EXTENSIONS--
4+
dom
5+
--CREDITS--
6+
YuanchengJiang
7+
--SKIPIF--
8+
<?php
9+
if (LIBXML_VERSION < 21300) die("skip Upstream libxml bug causes incorrect output, fixed in GNOME/libxml2@b8597f4");
10+
?>
11+
--FILE--
12+
<?php
13+
$element = new DOMElement("N", "W", "y");
14+
$attr = new DOMAttr("c" , "n");
15+
$doc = new DOMDocument();
16+
$doc->appendChild($element);
17+
$element->setAttributeNodeNS($attr);
18+
$attr->appendChild($doc->createEntityReference('amp'));
19+
echo $attr->value;
20+
?>
21+
--EXPECT--
22+
n&

0 commit comments

Comments
 (0)