]> 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 c712d904dd4c071abb3699b0deb4492415e8abcf..972749fcaee3a0c8b75a67dea31ec232766d8286 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ PHP                                                                        NEWS
 - Fixed open_basedir circumvention for mail.log. (Maksymilian Arciemowicz,
   Stas)
 - Fixed signature generation/validation for zip archives in ext/phar. (Greg)
+- Fixed memory leak in stream_is_local(). (Felipe)
 
 - Fixed bug #49132 (posix_times returns false without error).
   (phpbugs at gunnu dot us)
index 508a95c9b09fa02f057b4707b96c5312774549da..d0282e031d6d960cce3d6950c215fed269f40d06 100644 (file)
@@ -1463,8 +1463,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)