summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2014-05-21 13:11:56 +0800
committerXinchen Hui <laruence@php.net>2014-05-21 13:11:56 +0800
commit59d74db108a458d08792c59f8e92677ce8c41423 (patch)
treed9b1e2457dc7cd73f8db8e41166f5e8f7dc2ea5b
parent96617874bd5d9872dde39488bc272385764ff8e2 (diff)
downloadphp-git-59d74db108a458d08792c59f8e92677ce8c41423.tar.gz
Fixed segafult while stream is referenced by persistent resource (like dba)
-rw-r--r--main/streams/streams.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index c754bdc58c..3ed457365a 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -457,7 +457,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
_php_stream_flush(stream, 1 TSRMLS_CC);
/* If not called from the resource dtor, remove the stream from the resource list. */
- if ((close_options & PHP_STREAM_FREE_RSRC_DTOR) == 0) {
+ if ((close_options & PHP_STREAM_FREE_RSRC_DTOR) == 0 && stream->res) {
/* zend_list_delete actually only decreases the refcount; if we're
* releasing the stream, we want to actually delete the resource from
* the resource list, otherwise the resource will point to invalid memory.