Skip to content

Commit 177f87c

Browse files
committed
Fixed bug #73370
If len=0 malloc() is allowed to return NULL.
1 parent 247ce05 commit 177f87c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2017 PHP 7.0.18
44

5+
- Core:
6+
. Fixed bug #73370 (falsely exits with "Out of Memory" when using
7+
USE_ZEND_ALLOC=0). (Nikita)
8+
59
- Date:
610
. Fixed bug #72096 (Swatch time value incorrect for dates before 1970). (mcq8)
711

Zend/zend_alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,7 +2862,7 @@ static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void)
28622862
ZEND_API void * __zend_malloc(size_t len)
28632863
{
28642864
void *tmp = malloc(len);
2865-
if (EXPECTED(tmp)) {
2865+
if (EXPECTED(tmp || !len)) {
28662866
return tmp;
28672867
}
28682868
zend_out_of_memory();
@@ -2878,7 +2878,7 @@ ZEND_API void * __zend_calloc(size_t nmemb, size_t len)
28782878
ZEND_API void * __zend_realloc(void *p, size_t len)
28792879
{
28802880
p = realloc(p, len);
2881-
if (EXPECTED(p)) {
2881+
if (EXPECTED(p || !len)) {
28822882
return p;
28832883
}
28842884
zend_out_of_memory();

0 commit comments

Comments
 (0)