mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
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.
50 lines
1.2 KiB
PHP
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
|