]> granicus.if.org Git - php/commitdiff
Fix custom heap free
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 28 Jun 2019 07:13:45 +0000 (09:13 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 28 Jun 2019 07:13:45 +0000 (09:13 +0200)
This seems to be designed around the use-case where the custom
allocator is a wrapper around ZMM.

Zend/zend_alloc.c

index 8bf37bc5fdf5e31b0b4509e0caedaee214f74e58..618a66a9eaad138e4e708ce989884df4624daab2 100644 (file)
@@ -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;
        }