com php-src: Fix bug #72742 - memory allocator fails to realloc small block to large one: Zend/zend_alloc.c

From: Date: Wed, 17 Aug 2016 09:31:26 +0000
Subject: com php-src: Fix bug #72742 - memory allocator fails to realloc small block to large one: Zend/zend_alloc.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-93894@lists.php.net to get a copy of this message
Commit: 326ac100ac016cd5fc2c7367c97d64fa4b6932df Author: Stanislav Malyshev <stas@php.net> Sun, 14 Aug 2016 19:07:15 -0700 Committer: Anatol Belski <ab@php.net> Wed, 17 Aug 2016 11:31:26 +0200 Parents: 19c10bb629139c42f55f10c9c84dfe3ba29567c6 Branches: PHP-7.0.10 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=326ac100ac016cd5fc2c7367c97d64fa4b6932df Log: Fix bug #72742 - memory allocator fails to realloc small block to large one (cherry picked from commit c2a13ced4272f2e65d2773e2ea6ca11c1ce4a911) Bugs: https://bugs.php.net/72742 Changed paths: M Zend/zend_alloc.c Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 1876559..a79d67b 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1548,21 +1548,21 @@ static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, si ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted"); if (info & ZEND_MM_IS_SRUN) { - int old_bin_num, bin_num; - - old_bin_num = ZEND_MM_SRUN_BIN_NUM(info); + int old_bin_num = ZEND_MM_SRUN_BIN_NUM(info); old_size = bin_data_size[old_bin_num]; - bin_num = ZEND_MM_SMALL_SIZE_TO_BIN(size); - if (old_bin_num == bin_num) { + if (size <= ZEND_MM_MAX_SMALL_SIZE) { + int bin_num = ZEND_MM_SMALL_SIZE_TO_BIN(size); + if (old_bin_num == bin_num) { #if ZEND_DEBUG - dbg = zend_mm_get_debug_info(heap, ptr); - dbg->size = real_size; - dbg->filename = __zend_filename; - dbg->orig_filename = __zend_orig_filename; - dbg->lineno = __zend_lineno; - dbg->orig_lineno = __zend_orig_lineno; + dbg = zend_mm_get_debug_info(heap, ptr); + dbg->size = real_size; + dbg->filename = __zend_filename; + dbg->orig_filename = __zend_orig_filename; + dbg->lineno = __zend_lineno; + dbg->orig_lineno = __zend_orig_lineno; #endif - return ptr; + return ptr; + } } } else /* if (info & ZEND_MM_IS_LARGE_RUN) */ { ZEND_MM_CHECK(ZEND_MM_ALIGNED_OFFSET(page_offset, ZEND_MM_PAGE_SIZE) == 0, "zend_mm_heap corrupted");

« previous php.cvs (#93894) next »