cataphract Fri, 24 Feb 2012 22:56:21 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=323478
Log: - Better fix for #61115. - Fixed resource leak in stream_socket_client(). Bug: https://bugs.php.net/61115 (Closed) Stream related segfault on fatal error in php_stream_context_del_link Changed paths: U php/php-src/branches/PHP_5_3/ext/standard/streamsfuncs.c U php/php-src/branches/PHP_5_3/main/streams/streams.c U php/php-src/trunk/ext/standard/streamsfuncs.c U php/php-src/trunk/main/streams/streams.c Modified: php/php-src/branches/PHP_5_3/ext/standard/streamsfuncs.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/streamsfuncs.c 2012-02-24 20:11:11 UTC (rev 323477) +++ php/php-src/branches/PHP_5_3/ext/standard/streamsfuncs.c 2012-02-24 22:56:21 UTC (rev 323478) @@ -106,10 +106,6 @@ context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT); - if (context) { - zend_list_addref(context->rsrc_id); - } - if (flags & PHP_STREAM_CLIENT_PERSISTENT) { spprintf(&hashkey, 0, "stream_socket_client__%s", host); } Modified: php/php-src/branches/PHP_5_3/main/streams/streams.c =================================================================== --- php/php-src/branches/PHP_5_3/main/streams/streams.c 2012-02-24 20:11:11 UTC (rev 323477) +++ php/php-src/branches/PHP_5_3/main/streams/streams.c 2012-02-24 22:56:21 UTC (rev 323478) @@ -320,10 +320,15 @@ int remove_rsrc = 1; int preserve_handle = close_options & PHP_STREAM_FREE_PRESERVE_HANDLE ? 1 : 0; int release_cast = 1; - /* on an unclean shutdown, the context may have already been freed (if it - * was created after the stream resource), so don't reference it */ - php_stream_context *context = CG(unclean_shutdown) ? NULL : stream->context; + php_stream_context *context = NULL; + /* on an resource list destruction, the context, another resource, may have + * already been freed (if it was created after the stream resource), so + * don't reference it */ + if (!(close_options & PHP_STREAM_FREE_RSRC_DTOR)) { + context = stream->context; + } + if (stream->flags & PHP_STREAM_FLAG_NO_CLOSE) { preserve_handle = 1; } Modified: php/php-src/trunk/ext/standard/streamsfuncs.c =================================================================== --- php/php-src/trunk/ext/standard/streamsfuncs.c 2012-02-24 20:11:11 UTC (rev 323477) +++ php/php-src/trunk/ext/standard/streamsfuncs.c 2012-02-24 22:56:21 UTC (rev 323478) @@ -106,10 +106,6 @@ context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT); - if (context) { - zend_list_addref(context->rsrc_id); - } - if (flags & PHP_STREAM_CLIENT_PERSISTENT) { spprintf(&hashkey, 0, "stream_socket_client__%s", host); } Modified: php/php-src/trunk/main/streams/streams.c =================================================================== --- php/php-src/trunk/main/streams/streams.c 2012-02-24 20:11:11 UTC (rev 323477) +++ php/php-src/trunk/main/streams/streams.c 2012-02-24 22:56:21 UTC (rev 323478) @@ -366,10 +366,15 @@ int ret = 1; int preserve_handle = close_options & PHP_STREAM_FREE_PRESERVE_HANDLE ? 1 : 0; int release_cast = 1; - /* on an unclean shutdown, the context may have already been freed (if it - * was created after the stream resource), so don't reference it */ - php_stream_context *context = CG(unclean_shutdown) ? NULL : stream->context; + php_stream_context *context = NULL; + /* on an resource list destruction, the context, another resource, may have + * already been freed (if it was created after the stream resource), so + * don't reference it */ + if (!(close_options & PHP_STREAM_FREE_RSRC_DTOR)) { + context = stream->context; + } + if (stream->flags & PHP_STREAM_FLAG_NO_CLOSE) { preserve_handle = 1; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php