1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/ext/xmlreader/tests/gh16292.phpt
Niels Dossche 5c1249391b Fix GH-16292: Segmentation fault in ext/xmlreader/php_xmlreader.c:1282
3 issues:
1) RETURN_NULL() was used via the macro NODE_GET_OBJ(), but the function
   returns false on failure and cannot return null according to its
   stub.
2) The struct layout of the different implementors of libxml only
   guarantees overlap between the node pointer and the document
   reference, so accessing the std zend_object may not work.
3) DOC_GET_OBJ() wasn't using ZSTR_VAL().

Closes GH-16307.
2024-10-08 20:54:07 +02:00

27 lines
634 B
PHP

--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)