From: Wez Furlong Date: Sun, 17 Nov 2002 01:06:31 +0000 (+0000) Subject: Avoid a potential double fclose(). X-Git-Tag: php-4.3.0RC2~116 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d4fe01bb658d9acc01ff8d8a64d6406cf49e837;p=php Avoid a potential double fclose(). --- diff --git a/main/streams.c b/main/streams.c index bb6a3bd082..bf0633664d 100755 --- a/main/streams.c +++ b/main/streams.c @@ -1336,10 +1336,12 @@ static int php_stdiop_close(php_stream *stream, int close_handle TSRMLS_DC) assert(data != NULL); if (close_handle) { - if (data->is_process_pipe) { - ret = pclose(data->file); - } else { - ret = fclose(data->file); + if (data->file) { + if (data->is_process_pipe) { + ret = pclose(data->file); + } else { + ret = fclose(data->file); + } } if (data->temp_file_name) { unlink(data->temp_file_name); @@ -1347,6 +1349,7 @@ static int php_stdiop_close(php_stream *stream, int close_handle TSRMLS_DC) } } else { ret = 0; + data->file = NULL; } /* STDIO streams are never persistent! */