diff --git a/compat/mingw.c b/compat/mingw.c index 4626f98e522058..c077bfb9a48043 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1276,8 +1276,11 @@ char *mingw_mktemp(char *template) int offset = 0; /* we need to return the path, thus no long paths here! */ - if (xutftowcs_path(wtemplate, template) < 0) + if (xutftowcsn(wtemplate, template, MAX_PATH, -1) < 0) { + if (errno == ERANGE) + errno = ENAMETOOLONG; return NULL; + } if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) && iswalpha(wtemplate[0]) && wtemplate[1] == L':') {