Message ID | pull.1413.v3.git.git.1673189354738.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v3] mingw: check that the file attributes are valid before modifying them | expand |
diff --git a/compat/mingw.c b/compat/mingw.c index af397e68a1d..01bafa01e92 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -435,6 +435,11 @@ static inline int needs_hiding(const char *path) static int set_hidden_flag(const wchar_t *path, int set) { DWORD original = GetFileAttributesW(path), modified; + if (original == INVALID_FILE_ATTRIBUTES) { + errno = err_win_to_posix(GetLastError()); + return -1; + } + if (set) modified = original | FILE_ATTRIBUTE_HIDDEN; else