mirror of
https://github.com/php/php-src.git
synced 2024-11-23 01:44:06 +08:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-16292: Segmentation fault in ext/xmlreader/php_xmlreader.c:1282
This commit is contained in:
commit
dd0ced3046
@ -60,7 +60,7 @@ PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
|
||||
__intern = Z_LIBXML_NODE_P(__id); \
|
||||
if (UNEXPECTED(__intern->node == NULL)) { \
|
||||
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", \
|
||||
ZSTR_VAL(__intern->std.ce->name));\
|
||||
ZSTR_VAL(Z_OBJCE_P(__zv)->name));\
|
||||
RETURN_NULL();\
|
||||
} \
|
||||
__ptr = (__prtype)__intern->node->node; \
|
||||
|
@ -1279,7 +1279,13 @@ PHP_METHOD(XMLReader, expand)
|
||||
}
|
||||
|
||||
if (basenode != NULL) {
|
||||
NODE_GET_OBJ(node, basenode, xmlNodePtr, domobj);
|
||||
/* Note: cannot use NODE_GET_OBJ here because of the wrong return type */
|
||||
domobj = Z_LIBXML_NODE_P(basenode);
|
||||
if (UNEXPECTED(domobj->node == NULL)) {
|
||||
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(Z_OBJCE_P(basenode)->name));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
node = domobj->node->node;
|
||||
docp = node->doc;
|
||||
}
|
||||
|
||||
|
26
ext/xmlreader/tests/gh16292.phpt
Normal file
26
ext/xmlreader/tests/gh16292.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
GH-16292 (Segmentation fault in ext/xmlreader/php_xmlreader.c:1282)
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
xmlreader
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$character_data = new DOMCharacterData();
|
||||
$xmlstring = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<books><book>new book</book></books>';
|
||||
$reader = new XMLReader();
|
||||
$reader->XML($xmlstring);
|
||||
while ($reader->read()) {
|
||||
if ($reader->localName == "book") {
|
||||
var_dump($reader->expand($character_data));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: XMLReader::expand(): Couldn't fetch DOMCharacterData in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: XMLReader::expand(): Couldn't fetch DOMCharacterData in %s on line %d
|
||||
bool(false)
|
Loading…
Reference in New Issue
Block a user