[CRT]
authorAmine Khaldi <amine.khaldi@reactos.org>
Mon, 12 May 2014 12:50:55 +0000 (12:50 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Mon, 12 May 2014 12:50:55 +0000 (12:50 +0000)
* Update tmpfile().
CORE-8080

svn path=/trunk/; revision=63251

reactos/lib/sdk/crt/stdio/file.c

index 70673ba..275a1ef 100644 (file)
@@ -3346,16 +3346,20 @@ FILE* CDECL tmpfile(void)
   FILE* file = NULL;
 
   LOCK_FILES();
-  fd = _open(filename, _O_CREAT | _O_BINARY | _O_RDWR | _O_TEMPORARY);
+  fd = _open(filename, _O_CREAT | _O_BINARY | _O_RDWR | _O_TEMPORARY,
+          _S_IREAD | _S_IWRITE);
   if (fd != -1 && (file = alloc_fp()))
   {
-    if (init_fp(file, fd, _O_RDWR) == -1)
+    if (init_fp(file, fd, _IORW) == -1)
     {
         file->_flag = 0;
         file = NULL;
     }
     else file->_tmpfname = _strdup(filename);
   }
+
+  if(fd != -1 && !file)
+      _close(fd);
   UNLOCK_FILES();
   return file;
 }