]> granicus.if.org Git - php/commitdiff
Temorary fix for phpdbg segfault while use zend_mm_set_custom_handlers
authorXinchen Hui <laruence@php.net>
Mon, 9 Mar 2015 03:19:05 +0000 (11:19 +0800)
committerXinchen Hui <laruence@php.net>
Mon, 9 Mar 2015 03:19:05 +0000 (11:19 +0800)
Zend/zend_alloc.c
sapi/phpdbg/phpdbg.c

index b066eb0b1fb3d1c16fffe2244d42601637b1e6ce..6701ca49028b55e33893fc2ae8fee56d0a66ce5f 100644 (file)
@@ -1950,6 +1950,9 @@ void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent)
 
 #if ZEND_MM_CUSTOM
        if (heap->use_custom_heap) {
+               if (full) {
+                       heap->_free(heap);
+               }
                return;
        }
 #endif
index 74bf84adff94f65ac585398f5fb979e7fbf578de..a12811fb87d5235cc8beff09fe999c9e5d002b96 100644 (file)
@@ -983,7 +983,14 @@ void *phpdbg_malloc_wrapper(size_t size) /* {{{ */
 
 void phpdbg_free_wrapper(void *p) /* {{{ */
 {
-       zend_mm_free(phpdbg_mm_get_heap(), p);
+       zend_mm_heap *heap = phpdbg_mm_get_heap();
+       if (UNEXPECTED(heap == p)) {
+               /* TODO: heap maybe allocated by mmap(zend_mm_init) or malloc(USE_ZEND_ALLOC=0) 
+                * let's prevent it from segfault for now
+                */
+       } else {
+               zend_mm_free(heap, p);
+       }
 } /* }}} */
 
 void *phpdbg_realloc_wrapper(void *ptr, size_t size) /* {{{ */