Fix mkstemp implementation

When closing the file handle obtained from mkstemp(), the file
ought _not_ to be deleted.

Patch by Jan Engelhardt <jengelh@inai.de>
This commit is contained in:
Jonathan Yong 2016-03-02 18:02:25 +08:00
parent 4c13e3f141
commit 76119a8e89
No known key found for this signature in database
GPG Key ID: 713B5FE29C145D45

View File

@ -48,7 +48,7 @@ int __cdecl mkstemp (char *template_name)
template_name[j] = letters[rand () % 62];
}
fd = _sopen(template_name,
_O_RDWR | _O_CREAT | _O_EXCL | _O_TEMPORARY | _O_BINARY,
_O_RDWR | _O_CREAT | _O_EXCL | _O_BINARY,
_SH_DENYRW, _S_IREAD | _S_IWRITE);
if (fd != -1) return fd;
if (fd == -1 && errno != EEXIST) return -1;