Skip to content

Commit 3c111a7

Browse files
committed
Fix
1 parent 0d0886f commit 3c111a7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Zend/zend_alloc.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static size_t _real_page_size = ZEND_MM_PAGE_SIZE;
174174
#ifdef __SANITIZE_ADDRESS__
175175
# include <sanitizer/asan_interface.h>
176176

177-
#if 1
177+
#if 0
178178

179179
#define ZEND_MM_POISON_DEBUG(_type, _ptr, _size) do { \
180180
fprintf(stderr, "%s %p - %p in %d\n", (_type), (_ptr), (void*) (((size_t)_ptr)+((size_t)_size)), __LINE__); \
@@ -1271,7 +1271,15 @@ static zend_always_inline void zend_mm_delete_chunk(zend_mm_heap *heap, zend_mm_
12711271
heap->last_chunks_delete_count++;
12721272
}
12731273
}
1274+
1275+
if (heap->cached_chunks) {
1276+
ZEND_MM_UNPOISON_CHUNK_HDR(heap->cached_chunks);
1277+
}
1278+
12741279
if (!heap->cached_chunks || chunk->num > heap->cached_chunks->num) {
1280+
if (heap->cached_chunks) {
1281+
ZEND_MM_POISON_CHUNK_HDR(heap->cached_chunks, heap);
1282+
}
12751283
zend_mm_chunk_free(heap, chunk, ZEND_MM_CHUNK_SIZE);
12761284
} else {
12771285
//TODO: select the best chunk to delete???
@@ -1296,11 +1304,12 @@ static zend_always_inline void zend_mm_free_pages_ex(zend_mm_heap *heap, zend_mm
12961304
chunk->free_tail = page_num;
12971305
}
12981306
bool should_free = free_chunk && chunk != heap->main_chunk && chunk->free_pages == ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE;
1299-
ZEND_MM_POISON_CHUNK_HDR(chunk, heap);
13001307
ZEND_MM_POISON(ZEND_MM_PAGE_ADDR(chunk, page_num), pages_count * ZEND_MM_PAGE_SIZE);
13011308

13021309
if (should_free) {
13031310
zend_mm_delete_chunk(heap, chunk);
1311+
} else {
1312+
ZEND_MM_POISON_CHUNK_HDR(chunk, heap);
13041313
}
13051314
}
13061315

0 commit comments

Comments
 (0)