summaryrefslogtreecommitdiff
path: root/main/streams/streams.c
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2011-05-08 19:59:42 +0000
committerGustavo André dos Santos Lopes <cataphract@php.net>2011-05-08 19:59:42 +0000
commit8f77168384974b04eb9c12d4eb70452302539c9b (patch)
treef5cc7ad5be75e797467752d9fcd7c6bf7d5a7c9d /main/streams/streams.c
parentcde80bd812480728ebe137024a104478277ee345 (diff)
downloadphp-git-8f77168384974b04eb9c12d4eb70452302539c9b.tar.gz
- Merged to 5.3 change in trunk in _php_stream_free. This prevents the segfault
in the testcase for bug #53624. The testcase still has to be fixed though, because it only works as intended on Windows.
Diffstat (limited to 'main/streams/streams.c')
-rwxr-xr-xmain/streams/streams.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 22373016b6..aafb652a08 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -355,7 +355,12 @@ 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 && remove_rsrc) {
- zend_list_delete(stream->rsrc_id);
+ /* 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->rsrc_id) == SUCCESS) {}
}
/* Remove stream from any context link list */