@@ -201,6 +201,13 @@ static size_t _real_page_size = ZEND_MM_PAGE_SIZE;
201201
202202#define ZEND_MM_UNPOISON_CHUNK_HDR (_ptr ) ZEND_MM_UNPOISON((_ptr), sizeof(zend_mm_chunk));
203203
204+ #define ZEND_MM_POISON_CHUNK (_ptr , _heap ) do { \
205+ ZEND_MM_POISON((_ptr), ZEND_MM_CHUNK_SIZE); \
206+ ZEND_MM_UNPOISON_HEAP((_heap)); \
207+ } while (0);
208+
209+ #define ZEND_MM_UNPOISON_CHUNK (_ptr ) ZEND_MM_UNPOISON((_ptr), ZEND_MM_CHUNK_SIZE);
210+
204211#else
205212
206213#define ZEND_MM_POISON
@@ -209,6 +216,8 @@ static size_t _real_page_size = ZEND_MM_PAGE_SIZE;
209216#define ZEND_MM_UNPOISON_HEAP
210217#define ZEND_MM_POISON_CHUNK_HDR
211218#define ZEND_MM_UNPOISON_CHUNK_HDR
219+ #define ZEND_MM_POISON_CHUNK
220+ #define ZEND_MM_UNPOISON_CHUNK
212221
213222#endif
214223typedef uint32_t zend_mm_page_info ; /* 4-byte integer */
@@ -1211,7 +1220,7 @@ static zend_always_inline void zend_mm_delete_chunk(zend_mm_heap *heap, zend_mm_
12111220 heap -> cached_chunks_count ++ ;
12121221 chunk -> next = heap -> cached_chunks ;
12131222 heap -> cached_chunks = chunk ;
1214- ZEND_MM_POISON (chunk , ZEND_MM_CHUNK_SIZE );
1223+ ZEND_MM_POISON_CHUNK (chunk );
12151224 } else {
12161225#if ZEND_MM_STAT || ZEND_MM_LIMIT
12171226 heap -> real_size -= ZEND_MM_CHUNK_SIZE ;
@@ -1229,12 +1238,11 @@ static zend_always_inline void zend_mm_delete_chunk(zend_mm_heap *heap, zend_mm_
12291238 } else {
12301239//TODO: select the best chunk to delete???
12311240
1232- // Unpoison chunk before accessing the next pointer & freeing it
1233- ZEND_MM_UNPOISON (heap -> cached_chunks , ZEND_MM_CHUNK_SIZE );
1241+ ZEND_MM_UNPOISON_CHUNK_HDR (heap -> cached_chunks );
12341242 chunk -> next = heap -> cached_chunks -> next ;
12351243 zend_mm_chunk_free (heap , heap -> cached_chunks , ZEND_MM_CHUNK_SIZE );
12361244 heap -> cached_chunks = chunk ;
1237- ZEND_MM_POISON (chunk , ZEND_MM_CHUNK_SIZE );
1245+ ZEND_MM_POISON_CHUNK (chunk );
12381246 }
12391247 }
12401248}
@@ -2582,7 +2590,7 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
25822590 zend_mm_chunk * q = p -> next ;
25832591 p -> next = heap -> cached_chunks ;
25842592 heap -> cached_chunks = p ;
2585- ZEND_MM_POISON_CHUNK_HDR (p );
2593+ ZEND_MM_POISON_CHUNK (p );
25862594 p = q ;
25872595 ZEND_MM_UNPOISON_CHUNK_HDR (p );
25882596 heap -> chunks_count -- ;
0 commit comments