diff --git a/compat/mingw.c b/compat/mingw.c index c71e58593457ad..2bbe88a2059947 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1235,8 +1235,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':') {