File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ Author: CM Wintersteiger
12
12
#include < windows.h>
13
13
#include < io.h>
14
14
#include < direct.h>
15
+ #else
16
+ #include < vector>
15
17
#endif
16
18
17
19
#include < cstdlib>
@@ -64,9 +66,11 @@ std::string get_temporary_directory(const std::string &name_template)
64
66
prefixed_name_template+=' /' ;
65
67
prefixed_name_template+=name_template;
66
68
67
- char t[1000 ];
68
- strncpy (t, prefixed_name_template.c_str (), 1000 );
69
- const char *td = mkdtemp (t);
69
+ std::vector<char > t;
70
+ // add one byte for the zero
71
+ t.resize (prefixed_name_template.size ()+1 );
72
+ memcpy (t.data (), prefixed_name_template.c_str (), t.size ());
73
+ const char *td = mkdtemp (t.data ());
70
74
if (!td)
71
75
throw " mkdtemp failed" ;
72
76
result=std::string (td);
You can’t perform that action at this time.
0 commit comments