Skip to content

Commit d4f9d54

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix memory leak introduced by fixing bug #78221
2 parents cb338d8 + c3ee9d1 commit d4f9d54

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ext/dom/php_dom.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,14 @@ xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *l
13011301
/* }}} */
13021302
/* }}} end dom_element_get_elements_by_tag_name_ns_raw */
13031303

1304+
static inline zend_bool is_empty_node(xmlNodePtr nodep)
1305+
{
1306+
xmlChar *strContent = xmlNodeGetContent(nodep);
1307+
zend_bool ret = strContent == NULL || *strContent == '\0';
1308+
xmlFree(strContent);
1309+
return ret;
1310+
}
1311+
13041312
/* {{{ void dom_normalize (xmlNodePtr nodep) */
13051313
void dom_normalize (xmlNodePtr nodep)
13061314
{
@@ -1326,8 +1334,7 @@ void dom_normalize (xmlNodePtr nodep)
13261334
break;
13271335
}
13281336
}
1329-
strContent = xmlNodeGetContent(child);
1330-
if (*strContent == '\0') {
1337+
if (is_empty_node(child)) {
13311338
nextp = child->next;
13321339
xmlUnlinkNode(child);
13331340
php_libxml_node_free_resource(child);

0 commit comments

Comments
 (0)