mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
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:
parent
dee29442ba
commit
9d7e6090df
11
ext/dom/tests/gh15137.phpt
Normal file
11
ext/dom/tests/gh15137.phpt
Normal 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) ""
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user