]> granicus.if.org Git - php/commitdiff
- Re-fix stream_is_local() memory leaks
authorFelipe Pena <felipe@php.net>
Mon, 3 Aug 2009 13:16:24 +0000 (13:16 +0000)
committerFelipe Pena <felipe@php.net>
Mon, 3 Aug 2009 13:16:24 +0000 (13:16 +0000)
NEWS
ext/standard/streamsfuncs.c
ext/standard/tests/streams/stream_is_local.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 7409690049fcf374abfbc55ae5b97bf10c80e2dd..093e6423428e7dddc2c4cafebc8b4759bfe22665 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP                                                                        NEWS
 ?? ??? 2009, PHP 5.2.11
 - Fixed regression in cURL extension that prevented flush of data to output
   defined as a file handle. (Ilia)
+- Fixed memory leak in stream_is_local(). (Felipe)
 
 - Fixed bug #49132 (posix_times returns false without error).
   (phpbugs at gunnu dot us)
index 43182c80304bb24bf9d74db9205cafb61e923916..f3b333b39092c533a5b938b77fad6b6d68ae5163 100644 (file)
@@ -1397,8 +1397,17 @@ PHP_FUNCTION(stream_is_local)
                }
                wrapper = stream->wrapper;
        } else {
-               convert_to_string_ex(&zstream);
-               wrapper = php_stream_locate_url_wrapper(Z_STRVAL_P(zstream), NULL, 0 TSRMLS_CC);
+               zval *copy_tmp;
+               
+               ALLOC_ZVAL(copy_tmp);
+               *copy_tmp = *zstream;
+               zval_copy_ctor(copy_tmp);
+               INIT_PZVAL(copy_tmp);
+               convert_to_string(copy_tmp);
+               
+               wrapper = php_stream_locate_url_wrapper(Z_STRVAL_P(copy_tmp), NULL, 0 TSRMLS_CC);
+               
+               zval_ptr_dtor(&copy_tmp);
        }
 
        if(!wrapper) {
diff --git a/ext/standard/tests/streams/stream_is_local.phpt b/ext/standard/tests/streams/stream_is_local.phpt
new file mode 100644 (file)
index 0000000..c90eb19
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Testing stream_is_local()
+--FILE--
+<?php
+
+$a = 1;
+$b = $a;
+var_dump(stream_is_local($b));
+var_dump($b);
+
+var_dump(stream_is_local(fopen(__FILE__, 'r')));
+
+?>
+--EXPECT--
+bool(true)
+int(1)
+bool(true)