]> granicus.if.org Git - php/commitdiff
Fixed zero-size allocation in debug build
authorDmitry Stogov <dmitry@zend.com>
Tue, 26 Aug 2014 17:32:20 +0000 (21:32 +0400)
committerDmitry Stogov <dmitry@zend.com>
Tue, 26 Aug 2014 17:32:20 +0000 (21:32 +0400)
Zend/zend_alloc.c

index 7d7a481c8037682bb6fdc151db166b64ae213798..805cc856bfb5500f58991bd2c3ce4ccd9d54ff88 100644 (file)
@@ -1169,6 +1169,8 @@ static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t si
        size_t real_size = size;
        zend_mm_debug_info *dbg;
 
+       /* special handling for zero-size allocation */
+       size = MAX(size, 1);
        size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
 #endif
        if (size <= ZEND_MM_MAX_SMALL_SIZE) {