From: Eric Biggers Date: Tue, 27 Oct 2020 03:17:02 +0000 (-0700) Subject: win32_replacements.c: fix handle closing in win32_wglob() X-Git-Tag: v1.13.3~1 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=8a87f778734e10a2bb958d2e61c3185ef6970867 win32_replacements.c: fix handle closing in win32_wglob() 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. --- diff --git a/src/win32_replacements.c b/src/win32_replacements.c index c2fb556d..34d4e86a 100644 --- a/src/win32_replacements.c +++ b/src/win32_replacements.c @@ -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: