summaryrefslogtreecommitdiff
path: root/main/streams/streams.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2008-07-11 10:24:29 +0000
committerAntony Dovgal <tony2001@php.net>2008-07-11 10:24:29 +0000
commit3519ed9e3179e3669b14a87b94f4c49cd1e6d7a2 (patch)
tree1d49e66b0e693fa76df5a64b8c2a4452a4d153fb /main/streams/streams.c
parente5612456de0851d843b3adcc2d493225b82445e8 (diff)
downloadphp-git-3519ed9e3179e3669b14a87b94f4c49cd1e6d7a2.tar.gz
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 cbc3a25301..fe7f0ff915 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -288,6 +288,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;
@@ -428,6 +429,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;
}
/* }}} */
@@ -2414,6 +2419,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) {