Skip to content

Commit 18674e3

Browse files
committed
Fix is_zend_ptr() huge block comparison
We should compare the block memory, not the block metadata (See zend_mm_add_huge_block). This caused random test failure for ext/ffi/tests/gh14626.phpt when the malloc() performed by the FFI code lies close to the block metadata, and the size of the block is large enough. This was reported by #16902 (comment) Closes GH-16938.
1 parent d1b9d7e commit 18674e3

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ PHP NEWS
1414
(nielsdos)
1515
. Fixed bug GH-16630 (UAF in lexer with encoding translation and heredocs).
1616
(nielsdos)
17+
. Fix is_zend_ptr() huge block comparison. (nielsdos)
1718

1819
- FPM:
1920
. Fixed GH-16432 (PHP-FPM 8.2 SIGSEGV in fpm_get_status). (Jakub Zelenka)

Zend/zend_alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,8 +2457,8 @@ ZEND_API bool is_zend_ptr(const void *ptr)
24572457

24582458
zend_mm_huge_list *block = AG(mm_heap)->huge_list;
24592459
while (block) {
2460-
if (ptr >= (void*)block
2461-
&& ptr < (void*)((char*)block + block->size)) {
2460+
if (ptr >= block->ptr
2461+
&& ptr < (void*)((char*)block->ptr + block->size)) {
24622462
return 1;
24632463
}
24642464
block = block->next;

0 commit comments

Comments
 (0)