Skip to content

Commit

Permalink
Fix is_zend_ptr() huge block comparison
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
nielsdos committed Nov 25, 2024
1 parent ff3b4ec commit a78b32d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2457,8 +2457,8 @@ ZEND_API bool is_zend_ptr(const void *ptr)

zend_mm_huge_list *block = AG(mm_heap)->huge_list;
while (block) {
if (ptr >= (void*)block
&& ptr < (void*)((char*)block + block->size)) {
if (ptr >= block->ptr
&& ptr < (void*)((char*)block->ptr + block->size)) {
return 1;
}
block = block->next;
Expand Down

0 comments on commit a78b32d

Please sign in to comment.