Skip to content

Commit db994d2

Browse files
committed
Merge pull request #2488 from bmueller84/master
mingw: fix fatal error working on mapped network drives on Windows
2 parents 531ffae + f3151fe commit db994d2

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
@@ -1162,8 +1162,13 @@ char *mingw_getcwd(char *pointer, int len)
11621162
if (hnd != INVALID_HANDLE_VALUE) {
11631163
ret = GetFinalPathNameByHandleW(hnd, wpointer, ARRAY_SIZE(wpointer), 0);
11641164
CloseHandle(hnd);
1165-
if (!ret || ret >= ARRAY_SIZE(wpointer))
1166-
return NULL;
1165+
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
1166+
ret = GetLongPathNameW(cwd, wpointer, ARRAY_SIZE(wpointer));
1167+
if (!ret || ret >= ARRAY_SIZE(wpointer)) {
1168+
errno = ret ? ENAMETOOLONG : err_win_to_posix(GetLastError());
1169+
return NULL;
1170+
}
1171+
}
11671172
if (xwcstoutf(pointer, normalize_ntpath(wpointer), len) < 0)
11681173
return NULL;
11691174
return pointer;

0 commit comments

Comments
 (0)