]> wimlib.net Git - wimlib/commitdiff
win32_replacements.c: fix handle closing in win32_wglob()
authorEric Biggers <ebiggers3@gmail.com>
Tue, 27 Oct 2020 03:17:02 +0000 (20:17 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 27 Oct 2020 03:24:39 +0000 (20:24 -0700)
The handle returned by FindFirstFileW() needs to be closed by
FindClose(), not by CloseHandle().

This is a very old bug, which presumably wasn't noticed before because
ordinarily it just leaked the handle.  However, this bug caused a SEH
exception when wimlib was run under a debugger.

src/win32_replacements.c

index c2fb556d15553228412a535a606960118989e2ea..34d4e86a217d71d0208f04ba20bf39b7ecdc8eff 100644 (file)
@@ -692,7 +692,7 @@ win32_wglob(const wchar_t *pattern, int flags,
                pglob->gl_pathv[pglob->gl_pathc++] = path;
        } while (FindNextFileW(hFind, &dat));
        err = GetLastError();
-       CloseHandle(hFind);
+       FindClose(hFind);
        if (err != ERROR_NO_MORE_FILES) {
                set_errno_from_win32_error(err);
                ret = GLOB_ABORTED;
@@ -701,7 +701,7 @@ win32_wglob(const wchar_t *pattern, int flags,
        return 0;
 
 oom:
-       CloseHandle(hFind);
+       FindClose(hFind);
        errno = ENOMEM;
        ret = GLOB_NOSPACE;
 fail_globfree: