win,fs: avoid closing an invalid handle (#3473)

While usually functional, calling CloseHandle(INVALID_HANDLE_VALUE) can
result in debug builds (and/or wine) being unhappy and aborting there.
This commit is contained in:
Jameson Nash 2022-02-14 12:29:47 -05:00 committed by GitHub
parent 0209466496
commit 3b2c25d223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1880,8 +1880,9 @@ INLINE static DWORD fs__stat_impl_from_path(WCHAR* path,
NULL);
if (handle == INVALID_HANDLE_VALUE)
ret = GetLastError();
else if (fs__stat_handle(handle, statbuf, do_lstat) != 0)
return GetLastError();
if (fs__stat_handle(handle, statbuf, do_lstat) != 0)
ret = GetLastError();
else
ret = 0;
@ -2299,13 +2300,13 @@ INLINE static DWORD fs__utime_impl_from_path(WCHAR* path,
flags,
NULL);
if (handle == INVALID_HANDLE_VALUE) {
if (handle == INVALID_HANDLE_VALUE)
return GetLastError();
if (fs__utime_handle(handle, atime, mtime) != 0)
ret = GetLastError();
} else if (fs__utime_handle(handle, atime, mtime) != 0) {
ret = GetLastError();
} else {
else
ret = 0;
}
CloseHandle(handle);
return ret;