Bug #73370 [Asn]: falsely exits with "Out of Memory" when using USE_ZEND_ALLOC=0

From: Date: Wed, 02 Nov 2016 08:06:42 +0000
Subject: Bug #73370 [Asn]: falsely exits with "Out of Memory" when using USE_ZEND_ALLOC=0
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205138@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73370&edit=1

 ID:                 73370
 Updated by:         nikic@php.net
 Reported by:        jim dot hofer at gmail dot com
 Summary:            falsely exits with "Out of Memory" when using
                     USE_ZEND_ALLOC=0
 Status:             Assigned
 Type:               Bug
 Package:            MySQLi related
 Operating System:   Irrelevant
 PHP Version:        Irrelevant
 Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

Probably same code needed for __zend_realloc.

Instead of increasing the size to 1 we could instead only trigger the OOM condition if both !tmp and
!len. Not sure which is better.


Previous Comments:
------------------------------------------------------------------------
[2016-11-02 02:49:00] jim dot hofer at gmail dot com

I've applied the patch manually and it does not appear to fix the issue.

I'm not sure why the PHP Version was marked irrelevant either since this did not affect 7.0.11?

------------------------------------------------------------------------
[2016-10-25 19:51:20] jim dot hofer at gmail dot com

The source in the srpm i'm applying it to is

md5sum php-7.0.12.tar.xz
bdcc4dbdac90c2a39422786653059f70  php-7.0.12.tar.xz

which is the same checksum as the source on the downloads page.

what version is this patch supposed to be applied to?

------------------------------------------------------------------------
[2016-10-25 19:42:42] yohgaki@php.net

You should use plain source as we aren't responsible for packaging bug.

------------------------------------------------------------------------
[2016-10-25 16:02:58] jim dot hofer at gmail dot com

I've tried to apply the patch but it's being rejected.

I'm using php-7.0.12-2.remi.src.rpm to apply the patch and build the rpm

------------------------------------------------------------------------
[2016-10-22 07:07:52] laruence@php.net

please try follow patch:

diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 40eb100..5c9f124 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -2850,7 +2850,9 @@ static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void)

 ZEND_API void * __zend_malloc(size_t len)
 {
-   void *tmp = malloc(len);
+ void *tmp;
+ len = MAX(len, 1);
+ tmp = malloc(len);
        if (EXPECTED(tmp)) {
                return tmp;
        }

thanks

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=73370


--
Edit this bug report at https://bugs.php.net/bug.php?id=73370&edit=1


Thread (11 messages)

« previous php.bugs (#205138) next »