-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
3 changed files
with
89 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--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 |