From c00702cd6e5110202a02434a69efbacf6152ffdb Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 16 Oct 2012 17:23:04 +0200 Subject: [PATCH] msvcrt: Fixed tmpfile implementation. --- dlls/msvcrt/file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 59b7eb87202..d9ce98780fc 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -3754,16 +3754,20 @@ MSVCRT_FILE* CDECL MSVCRT_tmpfile(void) MSVCRT_FILE* file = NULL; LOCK_FILES(); - fd = MSVCRT__open(filename, MSVCRT__O_CREAT | MSVCRT__O_BINARY | MSVCRT__O_RDWR | MSVCRT__O_TEMPORARY); + fd = MSVCRT__open(filename, MSVCRT__O_CREAT | MSVCRT__O_BINARY | MSVCRT__O_RDWR | MSVCRT__O_TEMPORARY, + MSVCRT__S_IREAD | MSVCRT__S_IWRITE); if (fd != -1 && (file = msvcrt_alloc_fp())) { - if (msvcrt_init_fp(file, fd, MSVCRT__O_RDWR) == -1) + if (msvcrt_init_fp(file, fd, MSVCRT__IORW) == -1) { file->_flag = 0; file = NULL; } else file->_tmpfname = MSVCRT__strdup(filename); } + + if(fd != -1 && !file) + MSVCRT__close(fd); UNLOCK_FILES(); return file; }