Fix GH-15137: Unexpected null pointer in Zend/zend_smart_str.h (#15138)

This regressed when I optimized $wholeText. The previous code used xmlStrcat
which implicitly checked for a NULL argument, but now it's a direct memcpy
which you shouldn't pass null pointers to, although it won't result in a
crash because memcpy doesn't do anything if the length is 0.
This commit is contained in:
Niels Dossche 2024-07-28 13:53:30 +02:00 committed by GitHub
parent dee29442ba
commit 9d7e6090df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,11 @@
--TEST--
GH-15137: Unexpected null pointer in Zend/zend_smart_str.h
--EXTENSIONS--
dom
--FILE--
<?php
var_dump(new DOMText()->wholeText);
?>
--EXPECT--
string(0) ""

View File

@ -77,7 +77,9 @@ zend_result dom_text_whole_text_read(dom_object *obj, zval *retval)
/* concatenate all adjacent text and cdata nodes */
while (node && ((node->type == XML_TEXT_NODE) || (node->type == XML_CDATA_SECTION_NODE))) {
smart_str_appends(&str, (const char *) node->content);
if (node->content) {
smart_str_appends(&str, (const char *) node->content);
}
node = node->next;
}