fixes mkstemp file handle-leaking behavior (#529)
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
//*** For the Windows SDK _tempnam function ***//
|
//*** For the Windows SDK _tempnam function ***//
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -1091,8 +1092,11 @@ char *getTmpName(char *fname)
|
|||||||
// --- for non-Windows systems:
|
// --- for non-Windows systems:
|
||||||
#else
|
#else
|
||||||
// --- use system function mkstemp() to create a temporary file name
|
// --- use system function mkstemp() to create a temporary file name
|
||||||
|
int f = -1;
|
||||||
strcpy(fname, "enXXXXXX");
|
strcpy(fname, "enXXXXXX");
|
||||||
mkstemp(fname);
|
f = mkstemp(fname);
|
||||||
|
close(f);
|
||||||
|
remove(fname);
|
||||||
#endif
|
#endif
|
||||||
return fname;
|
return fname;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user