Re: cvs: php-src(PHP_5_2) /main/streams streams.c

From: Date: Thu, 22 Jun 2006 22:55:15 +0000
Subject: Re: cvs: php-src(PHP_5_2) /main/streams streams.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-38870@lists.php.net to get a copy of this message
On 6/22/06, Nuno Lopes <nlopess@php.net> wrote:
Hi,
@@ -1216,7 +1216,7 @@
              p = php_stream_mmap_range(src, php_stream_tell(src),
maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
-             if (p) {
+             if (p && mapped) {
                      *buf = pemalloc_rel_orig(mapped + 1, persistent);
                      if (*buf) {
I don't think this "fix" is correct. With your patch, PHP will do more 2 syscalls without any reason (because PHP will try to read the file again).
You'd rather have it if(p) {if(!mapped) return NULL; .... } ?
Anyway, I don't get any memory leak without your patch (at least with PHP 5.2). And take a look at _php_stream_passthru() or _php_stream_copy_to_stream(). If your patch is correct, these function would also need to be patched. Again, I get zero leaks.
You need debug build to reproduce it. I reproduced it in 5.1, 5.2 and HEAD.. I however can't reproduce leak in _php_stream_copy_to_stream nor _php_stream_passthru() -Hannes

« previous php.cvs (#38870) next »