Skip to content
Permalink
Browse files

fixup! mingw: ensure `getcwd()` reports the correct case

The return value of GetCurrentDirectoryW() upon errors is actually 0, not
negative (it cannot be negative, as DWORD is an *unsigned* data type).

Also, when converting from _wgetcwd(), I forgot to add errno explicitly...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information...
dscho committed May 5, 2017
1 parent c9743bc commit d4696aab496e0a7a5317e0d5af659292cd8c4324
Showing with 3 additions and 1 deletion.
  1. +3 −1 compat/mingw.c
@@ -1031,8 +1031,10 @@ char *mingw_getcwd(char *pointer, int len)
HANDLE, LPWSTR, DWORD, DWORD);
DWORD ret = GetCurrentDirectoryW(ARRAY_SIZE(cwd), cwd);

if (ret < 0 || ret >= ARRAY_SIZE(cwd))
if (!ret || ret >= ARRAY_SIZE(cwd)) {
errno = ret ? ENAMETOOLONG : err_win_to_posix(GetLastError());
return NULL;
}
ret = GetLongPathNameW(cwd, wpointer, ARRAY_SIZE(wpointer));
if (!ret && GetLastError() == ERROR_ACCESS_DENIED &&
INIT_PROC_ADDR(GetFinalPathNameByHandleW)) {

0 comments on commit d4696aa

Please sign in to comment.
You can’t perform that action at this time.