From 5b770e3a984cfa03702dfb3e62876d4834bd9ded Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Sep 2007 08:56:06 +0200 Subject: [PATCH] avoid using GetTempFileName in a way it's documented to not work on windows mysys/mf_tempfile.c: Try to avoid passing null as first parameter to GetTempFileName, since it's documented that it won't work. --- mysys/mf_tempfile.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c index c1108f85054..9460f27b104 100644 --- a/mysys/mf_tempfile.c +++ b/mysys/mf_tempfile.c @@ -59,11 +59,25 @@ File create_temp_file(char *to, const char *dir, const char *prefix, myf MyFlags __attribute__((unused))) { File file= -1; +#ifdef __WIN__ + TCHAR path_buf[MAX_PATH-14]; +#endif DBUG_ENTER("create_temp_file"); DBUG_PRINT("enter", ("dir: %s, prefix: %s", dir, prefix)); #if defined (__WIN__) + /* + Use GetTempPath to determine path for temporary files. + This is because the documentation for GetTempFileName + has the following to say about this parameter: + "If this parameter is NULL, the function fails." + */ + if (!dir) + { + if(GetTempPath(sizeof(path_buf), path_buf) > 0) + dir = path_buf; + } /* Use GetTempFileName to generate a unique filename, create the file and release it's handle