From 3fe5e6ee8a89cce691144e0a3d501be43d09c566 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Wed, 23 Nov 2011 12:32:45 +0100 Subject: [PATCH] msvcrt: Keep FILE critical section initialized after closing file. --- dlls/msvcrt/file.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index c636e85cb65..7a034d3159b 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -362,7 +362,12 @@ static MSVCRT_FILE* msvcrt_alloc_fp(void) if (file->_flag == 0) { - if (i == MSVCRT_stream_idx) MSVCRT_stream_idx++; + if (i == MSVCRT_stream_idx) + { + InitializeCriticalSection(&((file_crit*)file)->crit); + ((file_crit*)file)->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": file_crit.crit"); + MSVCRT_stream_idx++; + } return file; } } @@ -385,12 +390,6 @@ static int msvcrt_init_fp(MSVCRT_FILE* file, int fd, unsigned stream_flags) file->_file = fd; file->_flag = stream_flags; - if(file=MSVCRT__iob+_IOB_ENTRIES) - { - InitializeCriticalSection(&((file_crit*)file)->crit); - ((file_crit*)file)->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": file_crit.crit"); - } - TRACE(":got FILE* (%p)\n",file); return 0; } @@ -985,6 +984,16 @@ void msvcrt_free_io(void) for(i=0; i=MSVCRT__iob+_IOB_ENTRIES) + { + ((file_crit*)file)->crit.DebugInfo->Spare[0] = 0; + DeleteCriticalSection(&((file_crit*)file)->crit); + } + } + for(i=0; i_flag = 0; MSVCRT__unlock_file(file); - if(file=MSVCRT__iob+_IOB_ENTRIES) - { - ((file_crit*)file)->crit.DebugInfo->Spare[0] = 0; - DeleteCriticalSection(&((file_crit*)file)->crit); - } - - if(file == msvcrt_get_file(MSVCRT_stream_idx-1)) { - while(MSVCRT_stream_idx>3 && !file->_flag) { - MSVCRT_stream_idx--; - file = msvcrt_get_file(MSVCRT_stream_idx-1); - } - } return ((r == -1) || (flag & MSVCRT__IOERR) ? MSVCRT_EOF : 0); }