Skip to content

Commit c3ee9d1

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix memory leak introduced by fixing bug #78221
2 parents 8ff1991 + 7e91fcd commit c3ee9d1

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
@@ -1360,6 +1360,14 @@ xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *l
13601360
/* }}} */
13611361
/* }}} end dom_element_get_elements_by_tag_name_ns_raw */
13621362

1363+
static inline zend_bool is_empty_node(xmlNodePtr nodep)
1364+
{
1365+
xmlChar *strContent = xmlNodeGetContent(nodep);
1366+
zend_bool ret = strContent == NULL || *strContent == '\0';
1367+
xmlFree(strContent);
1368+
return ret;
1369+
}
1370+
13631371
/* {{{ void dom_normalize (xmlNodePtr nodep) */
13641372
void dom_normalize (xmlNodePtr nodep)
13651373
{
@@ -1385,8 +1393,7 @@ void dom_normalize (xmlNodePtr nodep)
13851393
break;
13861394
}
13871395
}
1388-
strContent = xmlNodeGetContent(child);
1389-
if (*strContent == '\0') {
1396+
if (is_empty_node(child)) {
13901397
nextp = child->next;
13911398
xmlUnlinkNode(child);
13921399
php_libxml_node_free_resource(child);

0 commit comments

Comments
 (0)