Skip to content

Commit f4fb6de

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Merge pull request #2488 from bmueller84/master
mingw: fix fatal error working on mapped network drives on Windows
2 parents e8bf96e + 83dc45c commit f4fb6de

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compat/mingw.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,8 +1257,13 @@ char *mingw_getcwd(char *pointer, int len)
12571257
if (hnd != INVALID_HANDLE_VALUE) {
12581258
ret = GetFinalPathNameByHandleW(hnd, wpointer, ARRAY_SIZE(wpointer), 0);
12591259
CloseHandle(hnd);
1260-
if (!ret || ret >= ARRAY_SIZE(wpointer))
1261-
return NULL;
1260+
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
1261+
ret = GetLongPathNameW(cwd, wpointer, ARRAY_SIZE(wpointer));
1262+
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
1263+
errno = ret ? ENAMETOOLONG : err_win_to_posix(GetLastError());
1264+
return NULL;
1265+
}
1266+
}
12621267
if (xwcstoutf(pointer, normalize_ntpath(wpointer), len) < 0)
12631268
return NULL;
12641269
return pointer;

0 commit comments

Comments
 (0)