On Win9x wide WinAPI functions return NULL handle (0) to indicate error
that function failed, instead of INVALID_HANDLE_VALUE handle (-1).
---
 mingw-w64-crt/stdio/_wfindfirst64.c | 2 +-
 mingw-w64-crt/stdio/_wstat32.c      | 2 +-
 mingw-w64-crt/stdio/_wstat64.c      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-crt/stdio/_wfindfirst64.c 
b/mingw-w64-crt/stdio/_wfindfirst64.c
index e8b1c8d6d064..b4f6cb0deaaa 100644
--- a/mingw-w64-crt/stdio/_wfindfirst64.c
+++ b/mingw-w64-crt/stdio/_wfindfirst64.c
@@ -19,7 +19,7 @@ static intptr_t __cdecl emu__wfindfirst64(const wchar_t 
*path, struct _wfinddata
     HANDLE handle;
 
     handle = FindFirstFileW(path, &win32_find_data);
-    win32_find_data_to_crt_find_data(handle != INVALID_HANDLE_VALUE, 
&win32_find_data, find_data);
+    win32_find_data_to_crt_find_data(handle != NULL && handle != 
INVALID_HANDLE_VALUE, &win32_find_data, find_data);
     return (intptr_t)handle;
 }
 
diff --git a/mingw-w64-crt/stdio/_wstat32.c b/mingw-w64-crt/stdio/_wstat32.c
index 6b0ac1b7e7fc..a3524e4064a0 100644
--- a/mingw-w64-crt/stdio/_wstat32.c
+++ b/mingw-w64-crt/stdio/_wstat32.c
@@ -66,7 +66,7 @@ int __cdecl _wstat32(const wchar_t *_Name,struct _stat32 
*_Stat)
   int err;
   HANDLE handle;
   handle = CreateFileW(_Name, FILE_READ_ATTRIBUTES, FILE_SHARE_VALID_FLAGS, 
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
-  if (handle == INVALID_HANDLE_VALUE) {
+  if (handle == NULL || handle == INVALID_HANDLE_VALUE) {
     switch (GetLastError()) {
     case ERROR_PATH_NOT_FOUND:
     case ERROR_FILE_NOT_FOUND:
diff --git a/mingw-w64-crt/stdio/_wstat64.c b/mingw-w64-crt/stdio/_wstat64.c
index 1ffaf6227a5b..c764daa20199 100644
--- a/mingw-w64-crt/stdio/_wstat64.c
+++ b/mingw-w64-crt/stdio/_wstat64.c
@@ -25,7 +25,7 @@ static int __cdecl emu__wstat64(const wchar_t *path, struct 
_stat64 *stat)
     stat->st_gid = st.st_gid;
     stat->st_rdev = st.st_rdev;
     handle = FindFirstFileW(path, &fi);
-    if (handle != INVALID_HANDLE_VALUE) {
+    if (handle != NULL && handle != INVALID_HANDLE_VALUE) {
         FindClose(handle);
         stat->st_size = ((_off64_t)fi.nFileSizeHigh << 32) | fi.nFileSizeLow;
         stat->st_atime = filetime_to_time64(&fi.ftLastAccessTime);
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to