msvcrt: Fixed tmpfile implementation.
This commit is contained in:
parent
7d128ea899
commit
c00702cd6e
|
@ -3754,16 +3754,20 @@ MSVCRT_FILE* CDECL MSVCRT_tmpfile(void)
|
||||||
MSVCRT_FILE* file = NULL;
|
MSVCRT_FILE* file = NULL;
|
||||||
|
|
||||||
LOCK_FILES();
|
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 (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->_flag = 0;
|
||||||
file = NULL;
|
file = NULL;
|
||||||
}
|
}
|
||||||
else file->_tmpfname = MSVCRT__strdup(filename);
|
else file->_tmpfname = MSVCRT__strdup(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(fd != -1 && !file)
|
||||||
|
MSVCRT__close(fd);
|
||||||
UNLOCK_FILES();
|
UNLOCK_FILES();
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue