]> granicus.if.org Git - php/commitdiff
Fixed segafult while stream is referenced by persistent resource (like dba)
authorXinchen Hui <laruence@php.net>
Wed, 21 May 2014 05:11:56 +0000 (13:11 +0800)
committerXinchen Hui <laruence@php.net>
Wed, 21 May 2014 05:11:56 +0000 (13:11 +0800)
main/streams/streams.c

index c754bdc58cb3dbab054fe4c949d61d7f457bfb19..3ed457365a8547f0c7b99cefb8566a58f8a1a385 100644 (file)
@@ -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.