diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2015-04-08 13:29:42 +0300 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2015-04-08 13:29:42 +0300 |
| commit | 4d9a1883aa764e502990488d2e8b9c978be6fbd2 (patch) | |
| tree | 1058bb04ebf8266a316c6449132e7cda7d0ce54b /main/streams/streams.c | |
| parent | fa795b05530c4ccd33ff63f23903bf4b458dc491 (diff) | |
| download | php-git-4d9a1883aa764e502990488d2e8b9c978be6fbd2.tar.gz | |
Fixed bug #68887 (resources are not freed correctly)
Diffstat (limited to 'main/streams/streams.c')
| -rw-r--r-- | main/streams/streams.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c index 886fc1da28..2358cc9df3 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -439,15 +439,10 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov /* If not called from the resource dtor, remove the stream from the resource list. */ 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. - * In any case, let's always completely delete it from the resource list, - * not only when PHP_STREAM_FREE_RELEASE_STREAM is set */ -//??? while (zend_list_delete(stream->res) == SUCCESS) {} -//??? stream->res->gc.refcount = 0; + /* Close resource, but keep it in resource list */ zend_list_close(stream->res); - if (!stream->__exposed) { + if ((close_options & PHP_STREAM_FREE_KEEP_RSRC) == 0) { + /* Completely delete zend_resource, if not referenced */ zend_list_delete(stream->res); stream->res = NULL; } |
