From c46c584f9753c9baf659cebfa291d0d1aca26f04 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Mon, 3 Aug 2009 13:16:24 +0000 Subject: [PATCH] - Re-fix stream_is_local() memory leaks --- NEWS | 1 + ext/standard/streamsfuncs.c | 13 +++++++++++-- ext/standard/tests/streams/stream_is_local.phpt | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 ext/standard/tests/streams/stream_is_local.phpt diff --git a/NEWS b/NEWS index 7409690049..093e642342 100644 --- 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) diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 43182c8030..f3b333b390 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -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(©_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 index 0000000000..c90eb19cde --- /dev/null +++ b/ext/standard/tests/streams/stream_is_local.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing stream_is_local() +--FILE-- + +--EXPECT-- +bool(true) +int(1) +bool(true) -- 2.40.0