diff --git a/mysys/mf_tempfile.cc b/mysys/mf_tempfile.cc index 7c1741541ab..aae26bf8451 100644 --- a/mysys/mf_tempfile.cc +++ b/mysys/mf_tempfile.cc @@ -89,7 +89,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix, #endif DBUG_ENTER("create_temp_file"); - DBUG_PRINT("enter", ("dir: %s, prefix: %s", dir, prefix)); + DBUG_PRINT("enter", ("dir: %s, prefix: %s", dir ? dir : "(null)", prefix)); #if defined(_WIN32) /* @@ -122,6 +122,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix, } #else /* mkstemp() is available on all non-Windows supported platforms. */ + if (!dir && !(dir = getenv("TMPDIR"))) dir = DEFAULT_TMPDIR; #ifdef O_TMPFILE { static int O_TMPFILE_works = 1; @@ -157,7 +158,6 @@ File create_temp_file(char *to, const char *dir, const char *prefix, sizeof(prefix_buff) - 7), "XXXXXX") - prefix_buff); - if (!dir && !(dir = getenv("TMPDIR"))) dir = DEFAULT_TMPDIR; if (strlen(dir) + pfx_len > FN_REFLEN - 2) { errno = ENAMETOOLONG; set_my_errno(ENAMETOOLONG);