-
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.
* PHP-8.3: [ci skip] NEWS for GH-14626 [ci skip] NEWS for GH-14626 Fix is_zend_ptr() for huge blocks (#14626)
- Loading branch information
Showing
6 changed files
with
78 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
GH-14626: is_zend_ptr() may crash for non-zend ptrs when huge blocks exist | ||
--EXTENSIONS-- | ||
zend_test | ||
--FILE-- | ||
<?php | ||
|
||
// Ensure there is at least one huge_block | ||
$str = str_repeat('a', 2*1024*1024); | ||
|
||
// Check that is_zend_ptr() does not crash | ||
zend_test_is_zend_ptr(0); | ||
zend_test_is_zend_ptr(1<<30); | ||
|
||
?> | ||
==DONE== | ||
--EXPECT-- | ||
==DONE== |
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,32 @@ | ||
--TEST-- | ||
GH-14626: FFI::free() may crash in is_zend_ptr() when at least one huge block exists and the ptr is non-zend | ||
--EXTENSIONS-- | ||
ffi | ||
--SKIPIF-- | ||
<?php | ||
if (substr(PHP_OS, 0, 3) == 'WIN') die("skip no malloc() on windows"); | ||
?> | ||
--INI-- | ||
ffi.enable=1 | ||
--FILE-- | ||
<?php | ||
|
||
// Ensure there is at least one huge_block | ||
$str = str_repeat('a', 2*1024*1024); | ||
|
||
$ffi = FFI::cdef(<<<C | ||
void *malloc(size_t size); | ||
C); | ||
|
||
$ptr = $ffi->malloc(10); | ||
$addr = $ffi->cast("uintptr_t", $ffi->cast("char*", $ptr))->cdata; | ||
|
||
$ptr = FFI::cdef()->cast("char*", $addr); | ||
|
||
// Should not crash in is_zend_ptr() | ||
FFI::free($ptr); | ||
|
||
?> | ||
==DONE== | ||
--EXPECT-- | ||
==DONE== |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.