1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/simplexml/tests/gh15837.phpt
Niels Dossche b5834c12d4 Fix GH-15837: Segmentation fault in ext/simplexml/simplexml.c
We should check if the iterator data is still valid, because if it
isn't, then the type info is UNDEF, but the pointer value may be
dangling.

Closes GH-15841.
2024-09-11 20:38:38 +02:00

31 lines
572 B
PHP

--TEST--
GH-15837 (Segmentation fault in ext/simplexml/simplexml.c)
--CREDITS--
YuanchengJiang
--FILE--
<?php
$xml =<<<EOF
<xml>
<fieldset1>
</fieldset1>
<fieldset2>
<options>
</options>
</fieldset2>
</xml>
EOF;
$sxe = new SimpleXMLIterator($xml);
$rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($rit as $child) {
$ancestry = $child->xpath('ancestor-or-self::*');
// Exhaust internal iterator
foreach ($ancestry as $ancestor) {
}
}
var_dump($rit->valid());
var_dump($rit->key());
?>
--EXPECT--
bool(false)
NULL