cvs: php4(PHP_4_3) /main streams.c

From: Date: Thu, 15 May 2003 12:01:01 +0000
Subject: cvs: php4(PHP_4_3) /main streams.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-20925@lists.php.net to get a copy of this message
sas Thu May 15 08:01:01 2003 EDT Modified files: (Branch: PHP_4_3) /php4/main streams.c Log: Avoid using a stream which has already been freed Index: php4/main/streams.c diff -u php4/main/streams.c:1.125.2.57 php4/main/streams.c:1.125.2.58 --- php4/main/streams.c:1.125.2.57 Wed May 14 15:10:02 2003 +++ php4/main/streams.c Thu May 15 08:01:01 2003 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.125.2.57 2003/05/14 19:10:02 wez Exp $ */ +/* $Id: streams.c,v 1.125.2.58 2003/05/15 12:01:01 sas Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -2710,18 +2710,23 @@ 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;

« previous php.cvs (#20925) next »