Skip to content

Commit a78b32d

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)
1 parent ff3b4ec commit a78b32d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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)