]> granicus.if.org Git - php/commitdiff
Fixed bug #73370
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 9 Mar 2017 19:47:06 +0000 (20:47 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 9 Mar 2017 19:47:06 +0000 (20:47 +0100)
If len=0 malloc() is allowed to return NULL.

NEWS
Zend/zend_alloc.c

diff --git a/NEWS b/NEWS
index a5fdf55916186ca5e9faef16e64fe416f12e2bd5..820d908e7d804c0f6f781090b74da02d08da0b03 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2017 PHP 7.0.18
 
+- Core:
+  . Fixed bug #73370 (falsely exits with "Out of Memory" when using
+    USE_ZEND_ALLOC=0). (Nikita)
+
 - Date:
   . Fixed bug #72096 (Swatch time value incorrect for dates before 1970). (mcq8)
 
index 14cc0d52a00a1e45797d84a7b1c36317b85b03f5..48def78a41dc0e8f0f01bc18a0a16949b08b8422 100644 (file)
@@ -2862,7 +2862,7 @@ static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void)
 ZEND_API void * __zend_malloc(size_t len)
 {
        void *tmp = malloc(len);
-       if (EXPECTED(tmp)) {
+       if (EXPECTED(tmp || !len)) {
                return tmp;
        }
        zend_out_of_memory();
@@ -2878,7 +2878,7 @@ ZEND_API void * __zend_calloc(size_t nmemb, size_t len)
 ZEND_API void * __zend_realloc(void *p, size_t len)
 {
        p = realloc(p, len);
-       if (EXPECTED(p)) {
+       if (EXPECTED(p || !len)) {
                return p;
        }
        zend_out_of_memory();