Skip to content

Commit

Permalink
Temorary fix for phpdbg segfault while use zend_mm_set_custom_handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Mar 9, 2015
1 parent 69d183d commit 96f7a33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion sapi/phpdbg/phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) /* {{{ */
Expand Down

0 comments on commit 96f7a33

Please sign in to comment.