summaryrefslogtreecommitdiff
path: root/main/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/main.c')
-rw-r--r--main/main.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/main/main.c b/main/main.c
index e3faf52d88..187286ad49 100644
--- a/main/main.c
+++ b/main/main.c
@@ -572,11 +572,10 @@ static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path
/* no need for us to check the stream type here */
php_stream_sock_set_chunk_size(stream, 1);
- if (php_stream_cast(stream, PHP_STREAM_AS_STDIO | PHP_STREAM_CAST_TRY_HARD, (void**)&retval, 1) == SUCCESS) {
- /* The leak here prevents a segfault */
- /* ZEND_REGISTER_RESOURCE(NULL, stream, php_file_le_stream()); */
- }
- else {
+ /* when this succeeds, stream either has or will be freed automatically */
+ if (php_stream_cast(stream, PHP_STREAM_AS_STDIO|PHP_STREAM_CAST_TRY_HARD|PHP_STREAM_CAST_RELEASE,
+ (void**)&retval, REPORT_ERRORS) == FAILURE)
+ {
php_stream_close(stream);
if (opened_path && *opened_path)
efree(*opened_path);