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/spl/tests/gh20856.phpt
Niels Dossche 2a2e0e8128 Fix GH-20856: heap-use-after-free in SplDoublyLinkedList iterator when modifying during iteration
The element may be still in use in other places, so the linking pointers
should be kept consistent. If not consistent, the "move forward" code in
the sample test will read a stale, dangling pointer.

Closes GH-20885.
2026-01-11 20:42:25 +01:00

27 lines
446 B
PHP

--TEST--
GH-20856 (heap-use-after-free in SplDoublyLinkedList iterator when modifying during iteration)
--CREDITS--
vi3tL0u1s
iluuu1994
--FILE--
<?php
$m = new SplStack;
$m[] = new stdClass;
$m[] = new stdClass;
foreach ($m as $l) {
unset($m[0]);
unset($m[0]);
}
var_dump($m);
?>
--EXPECTF--
object(SplStack)#%d (%d) {
["flags":"SplDoublyLinkedList":private]=>
int(6)
["dllist":"SplDoublyLinkedList":private]=>
array(0) {
}
}