We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 41d7a45 commit 1059b35Copy full SHA for 1059b35
src/util/tempdir.cpp
@@ -12,6 +12,8 @@ Author: CM Wintersteiger
12
#include <windows.h>
13
#include <io.h>
14
#include <direct.h>
15
+#else
16
+#include <vector>
17
#endif
18
19
#include <cstdlib>
@@ -64,9 +66,9 @@ std::string get_temporary_directory(const std::string &name_template)
64
66
prefixed_name_template+='/';
65
67
prefixed_name_template+=name_template;
68
- char t[1000];
- strncpy(t, prefixed_name_template.c_str(), 1000);
69
- const char *td = mkdtemp(t);
+ std::vector<char> t(prefixed_name_template.begin(), prefixed_name_template.end());
70
+ t.push_back('\0'); // add the zero
71
+ const char *td = mkdtemp(t.data());
72
if(!td)
73
throw "mkdtemp failed";
74
result=std::string(td);
0 commit comments