summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-02-24 22:56:21 +0000
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-02-24 22:56:21 +0000
commitbcefc31e68883448673c69ad9de6179d66db9c5b (patch)
treeb29a042a5810a2852a75a6dba2e6fa989226525c /main
parent48666d9ffc064a16e0ec2f30a87ea518d93b2809 (diff)
downloadphp-git-bcefc31e68883448673c69ad9de6179d66db9c5b.tar.gz
- Better fix for #61115.
- Fixed resource leak in stream_socket_client().
Diffstat (limited to 'main')
-rwxr-xr-xmain/streams/streams.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 39e2976518..7162ee8220 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -320,9 +320,14 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC) /*
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;