From e1818aae0affcf551a45748c7bcfc65426cf8b41 Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Thu, 15 May 2003 12:01:01 +0000 Subject: [PATCH] Avoid using a stream which has already been freed --- main/streams.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/streams.c b/main/streams.c index 8214545f9b..2cb7380b6f 100755 --- a/main/streams.c +++ b/main/streams.c @@ -2710,18 +2710,23 @@ PHPAPI FILE * _php_stream_open_wrapper_as_file(char *path, char *mode, int optio PHPAPI zend_bool _php_stream_open_wrapper_as_file_handle(char *path, char *mode, int options, zend_file_handle *fh STREAMS_DC TSRMLS_DC) { php_stream *stream = NULL; + int is_sock = 0; stream = php_stream_open_wrapper_rel(path, mode, options|STREAM_WILL_CAST, &fh->opened_path); if (stream == NULL) return FAILURE; + if ((options & STREAM_OPEN_FOR_INCLUDE) + && php_stream_is(stream, PHP_STREAM_IS_SOCKET)) { + is_sock = 1; + } + if (php_stream_can_cast(stream, PHP_STREAM_AS_FD) == SUCCESS && php_stream_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE, (void **) &fh->handle.fd, REPORT_ERRORS) == SUCCESS) { - if ((options & STREAM_OPEN_FOR_INCLUDE) - && php_stream_is(stream, PHP_STREAM_IS_SOCKET)) { + if (is_sock) { fh->type = ZEND_HANDLE_SOCKET_FD; } else { fh->type = ZEND_HANDLE_FD; -- 2.40.0