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/gh16337.phpt
Niels Dossche a56ff4fec7 Fix GH-16337: Use-after-free in SplHeap
We introduce a new flag to indicate when a heap or priority queue is
write-locked. In principle we could've used SPL_HEAP_CORRUPTED too, but
that won't be descriptive to users (and it's a lie too).

Closes GH-16346.
2024-10-12 13:31:23 +02:00

50 lines
1.2 KiB
PHP

--TEST--
GH-16337 (Use-after-free in SplHeap)
--FILE--
<?php
class C {
function __toString() {
global $heap;
try {
$heap->extract();
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
}
try {
$heap->insert(1);
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
}
echo $heap->top(), "\n";
return "0";
}
}
$heap = new SplMinHeap;
for ($i = 0; $i < 100; $i++) {
$heap->insert((string) $i);
}
$heap->insert(new C);
?>
--EXPECT--
Heap cannot be changed when it is already being modified.
Heap cannot be changed when it is already being modified.
0
Heap cannot be changed when it is already being modified.
Heap cannot be changed when it is already being modified.
0
Heap cannot be changed when it is already being modified.
Heap cannot be changed when it is already being modified.
0
Heap cannot be changed when it is already being modified.
Heap cannot be changed when it is already being modified.
0
Heap cannot be changed when it is already being modified.
Heap cannot be changed when it is already being modified.
0
Heap cannot be changed when it is already being modified.
Heap cannot be changed when it is already being modified.
0