summaryrefslogtreecommitdiff
path: root/main/streams/streams.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2008-07-11 10:25:15 +0000
committerAntony Dovgal <tony2001@php.net>2008-07-11 10:25:15 +0000
commitcf7e15c3a0fb44f57298c1761a373ca08a6d4a9d (patch)
tree01f29a896bb67c620cb1a02d1ea28506c71c34a4 /main/streams/streams.c
parent46f41aded18fe844e00385fb670a321bf2a75837 (diff)
downloadphp-git-cf7e15c3a0fb44f57298c1761a373ca08a6d4a9d.tar.gz
MFH: manage references of stream context properly
Diffstat (limited to 'main/streams/streams.c')
-rwxr-xr-xmain/streams/streams.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 03aea23f60..14bbcd2657 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -287,6 +287,7 @@ 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;
+ php_stream_context *context = stream->context;
if (stream->flags & PHP_STREAM_FLAG_NO_CLOSE) {
preserve_handle = 1;
@@ -427,6 +428,10 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
#endif
}
+ if (context) {
+ zend_list_delete(context->rsrc_id);
+ }
+
return ret;
}
/* }}} */
@@ -1801,6 +1806,10 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio
opened_path, context STREAMS_REL_CC TSRMLS_CC);
}
+ if (context) {
+ zend_list_addref(context->rsrc_id);
+ }
+
/* if the caller asked for a persistent stream but the wrapper did not
* return one, force an error here */
if (stream && (options & STREAM_OPEN_PERSISTENT) && !stream->is_persistent) {