diff options
| author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-02-24 22:56:21 +0000 | 
|---|---|---|
| committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-02-24 22:56:21 +0000 | 
| commit | 911330e62c7eb3124c137240315a70229d1471cc (patch) | |
| tree | a398c4d95d8e22de000acd2d784da7675bdfd0b0 | |
| parent | f434afe23640087d4ce60093342b500588588dc4 (diff) | |
| download | php-git-911330e62c7eb3124c137240315a70229d1471cc.tar.gz | |
- Better fix for #61115.
- Fixed resource leak in stream_socket_client().
| -rw-r--r-- | ext/standard/streamsfuncs.c | 4 | ||||
| -rwxr-xr-x | main/streams/streams.c | 11 | 
2 files changed, 8 insertions, 7 deletions
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index c903c57594..86e0bc6e60 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -106,10 +106,6 @@ PHP_FUNCTION(stream_socket_client)  	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);  	} diff --git a/main/streams/streams.c b/main/streams/streams.c index 2ee6083647..d8bb9d3c7a 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -366,9 +366,14 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC) /*  	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;  | 
