]> granicus.if.org Git - php/commitdiff
not all stream wrappers use context, so no need to addref in all cases
authorAntony Dovgal <tony2001@php.net>
Fri, 11 Jul 2008 12:40:20 +0000 (12:40 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 11 Jul 2008 12:40:20 +0000 (12:40 +0000)
main/streams/streams.c

index fe7f0ff915e983b78caf0b20d92e2f4585955dbc..f1b74a49d5ad7b89098b03e0c9a8c220403f14cc 100755 (executable)
@@ -2419,8 +2419,9 @@ 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);
+               /* increase context refcount only if the context is really used */
+               if (stream && stream->context) {
+                       zend_list_addref(stream->context->rsrc_id);
                }
 
                /* if the caller asked for a persistent stream but the wrapper did not