summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rwxr-xr-xmain/streams/streams.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 39e2976518..7162ee8220 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -320,9 +320,14 @@ 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;
- /* 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;