diff options
| author | Felipe Pena <felipe@php.net> | 2009-11-15 20:30:57 +0000 |
|---|---|---|
| committer | Felipe Pena <felipe@php.net> | 2009-11-15 20:30:57 +0000 |
| commit | 5411bb32a8f2da134ce38ec202aeff29d68da20d (patch) | |
| tree | 946ce64ec9706e7839bcd5cbcc989e7b916d9217 /main/streams/streams.c | |
| parent | 64f530d182c4b49850fb0b333b6f083acf558a0e (diff) | |
| download | php-git-5411bb32a8f2da134ce38ec202aeff29d68da20d.tar.gz | |
- Fixed bug #49936 (crash with ftp stream in php_stream_context_get_option())
(patch by Pierrick)
Diffstat (limited to 'main/streams/streams.c')
| -rwxr-xr-x | main/streams/streams.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c index 6bbe09be59..fbfc1af5ee 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1858,22 +1858,9 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, "wrapper does not support stream open"); } else { - /* refcount++ to make sure the context doesn't get destroyed - * if open() fails and stream is closed */ - if (context) { - zend_list_addref(context->rsrc_id); - } - stream = wrapper->wops->stream_opener(wrapper, path_to_open, mode, options ^ REPORT_ERRORS, opened_path, context STREAMS_REL_CC TSRMLS_CC); - - /* if open() succeeded and context was not used, do refcount-- - * XXX if a wrapper didn't actually use context (no way to know that) - * and open() failed, refcount will stay increased */ - if (context && stream && !stream->context) { - zend_list_delete(context->rsrc_id); - } } /* if the caller asked for a persistent stream but the wrapper did not @@ -1971,10 +1958,19 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio /* }}} */ /* {{{ context API */ -PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context) +PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context TSRMLS_DC) { php_stream_context *oldcontext = stream->context; + stream->context = context; + + if (context) { + zend_list_addref(context->rsrc_id); + } + if (oldcontext) { + zend_list_delete(oldcontext->rsrc_id); + } + return oldcontext; } |
