From: Nikita Popov Date: Fri, 28 Jun 2019 07:13:45 +0000 (+0200) Subject: Fix custom heap free X-Git-Tag: php-7.4.0alpha3~152 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70fa4715a4209049769b8a62687f15e403183120;p=php Fix custom heap free This seems to be designed around the use-case where the custom allocator is a wrapper around ZMM. --- diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 8bf37bc5fd..618a66a9ea 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2203,11 +2203,17 @@ void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent) if (full) { zend_hash_destroy(heap->tracked_allocs); free(heap->tracked_allocs); + /* Make sure the heap free below does not use tracked_free(). */ + heap->custom_heap.std._free = free; } } if (full) { - free(heap); + if (ZEND_DEBUG && heap->use_custom_heap == ZEND_MM_CUSTOM_HEAP_DEBUG) { + heap->custom_heap.debug._free(heap ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC); + } else { + heap->custom_heap.std._free(heap); + } } return; }