Skip to content

Commit ea1590d

Browse files
committed
Use tmpnam_s for temporary filename on Windows
1 parent 69afa6e commit ea1590d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Helpers.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ bool Helpers::starts_with(const std::string &str, const std::string &starting)
3030
std::string Helpers::temporary_filename()
3131
{
3232
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
33-
return std::tmpnam(nullptr);
33+
char filename[L_tmpnam_s];
34+
tmpnam_s(filename, L_tmpnam_s);
35+
36+
return filename;
3437
#else
3538
auto filename = fs::temp_directory_path().u8string() + "XXXXXXXXXXXXXXXX";
3639
mkstemp(filename.data());

0 commit comments

Comments
 (0)