diff options
author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-02-22 11:45:26 +0000 |
---|---|---|
committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-02-22 11:45:26 +0000 |
commit | eb1ada852dcb5490a6e899e85de0bde63f1a5bfc (patch) | |
tree | ca3c72d6c8dba6c59e3893ab40a41bf47efd967c /main/streams/streams.c | |
parent | 69f24fb50276efb0226d22896a420c90a1c09cd1 (diff) | |
download | php-git-eb1ada852dcb5490a6e899e85de0bde63f1a5bfc.tar.gz |
- Fixed bug #61115 (stream related segfault on fatal error in
php_stream_context_link).
#run-tests.php is not currently detecting the segfault in the test
#Missing 5.4 merge
Diffstat (limited to 'main/streams/streams.c')
-rwxr-xr-x | main/streams/streams.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c index af9f49f451..39e2976518 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -320,7 +320,9 @@ 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; + /* 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; if (stream->flags & PHP_STREAM_FLAG_NO_CLOSE) { preserve_handle = 1; @@ -374,8 +376,8 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov } /* Remove stream from any context link list */ - if (stream->context && stream->context->links) { - php_stream_context_del_link(stream->context, stream); + if (context && context->links) { + php_stream_context_del_link(context, stream); } if (close_options & PHP_STREAM_FREE_CALL_DTOR) { |