diff --git a/compat/mingw.c b/compat/mingw.c index 97b857915355da..b1bd925c701ed0 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1409,8 +1409,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':') {