Skip to content

Commit

Permalink
Only close handle streams which have been opened by zend_stream_fixup()
Browse files Browse the repository at this point in the history
  • Loading branch information
cmb69 committed Sep 6, 2022
1 parent c7f24d9 commit 0b148ea
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Zend/zend_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,17 @@ ZEND_API zend_result zend_stream_fixup(zend_file_handle *file_handle, char **buf
return SUCCESS;
} /* }}} */

/* Closes handle stream if opened by zend_stream_fixup() */
ZEND_API void zend_stream_close(zend_file_handle *fh) /* {{{ */
{
if (fh->type == ZEND_HANDLE_STREAM && fh->handle.stream.handle
&& fh->handle.stream.closer == (zend_stream_closer_t)zend_stream_stdio_closer) {
fh->handle.stream.closer(fh->handle.stream.handle);
fh->handle.stream.closer = NULL;
}
} /* }}} */

static void zend_file_handle_dtor(zend_file_handle *fh) /* {{{ */
{
switch (fh->type) {
case ZEND_HANDLE_FP:
Expand All @@ -231,11 +241,6 @@ ZEND_API void zend_stream_close(zend_file_handle *fh) /* {{{ */
*/
break;
}
} /* }}} */

static void zend_file_handle_dtor(zend_file_handle *fh) /* {{{ */
{
zend_stream_close(fh);
if (fh->opened_path) {
zend_string_release_ex(fh->opened_path, 0);
fh->opened_path = NULL;
Expand Down

0 comments on commit 0b148ea

Please sign in to comment.