Skip to content

Commit 517e8ce

Browse files
nielsdoscharmitro
authored andcommitted
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 php#16902 (comment) Closes phpGH-16938.
1 parent 71274f2 commit 517e8ce

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
@@ -2617,8 +2617,8 @@ ZEND_API bool is_zend_ptr(const void *ptr)
26172617

26182618
zend_mm_huge_list *block = AG(mm_heap)->huge_list;
26192619
while (block) {
2620-
if (ptr >= (void*)block
2621-
&& ptr < (void*)((char*)block + block->size)) {
2620+
if (ptr >= block->ptr
2621+
&& ptr < (void*)((char*)block->ptr + block->size)) {
26222622
return 1;
26232623
}
26242624
block = block->next;

0 commit comments

Comments
 (0)