com php-src: emalloc() must not return NULL: Zend/zend_alloc .c

From: Date: Tue, 16 Sep 2014 09:53:26 +0000
Subject: com php-src: emalloc() must not return NULL: Zend/zend_alloc .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81678@lists.php.net to get a copy of this message
Commit: 13be4a5a4bca457512eadbb1c351597dd88f3031 Author: Dmitry Stogov <dmitry@zend.com> Tue, 16 Sep 2014 13:53:26 +0400 Parents: ca37c02520d3129fd075ee103fee41d8545ba6dc Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=13be4a5a4bca457512eadbb1c351597dd88f3031 Log: emalloc() must not return NULL Changed paths: M Zend/zend_alloc.c Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 00cdd04..f35837b 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -882,6 +882,13 @@ not_found: chunk = (zend_mm_chunk*)zend_mm_chunk_alloc(ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE); if (UNEXPECTED(chunk == NULL)) { /* insufficient memory */ +#if !ZEND_MM_LIMIT + zend_mm_safe_error(heap, "Out of memory"); +#elif ZEND_DEBUG + zend_mm_safe_error(heap, "Out of memory (allocated %ld) at %s:%d (tried to allocate %lu bytes)", heap->real_size, __zend_filename, __zend_lineno, size); +#else + zend_mm_safe_error(heap, "Out of memory (allocated %ld) (tried to allocate %lu bytes)", heap->real_size, ZEND_MM_PAGE_SIZE * pages_count); +#endif return NULL; } #if ZEND_MM_STAT @@ -1545,6 +1552,13 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D ptr = zend_mm_chunk_alloc(new_size, ZEND_MM_CHUNK_SIZE); if (UNEXPECTED(ptr == NULL)) { /* insufficient memory */ +#if !ZEND_MM_LIMIT + zend_mm_safe_error(heap, "Out of memory"); +#elif ZEND_DEBUG + zend_mm_safe_error(heap, "Out of memory (allocated %ld) at %s:%d (tried to allocate %lu bytes)", heap->real_size, __zend_filename, __zend_lineno, size); +#else + zend_mm_safe_error(heap, "Out of memory (allocated %ld) (tried to allocate %lu bytes)", heap->real_size, size); +#endif return NULL; } #if ZEND_DEBUG

« previous php.cvs (#81678) next »