From 8a87f778734e10a2bb958d2e61c3185ef6970867 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 26 Oct 2020 20:17:02 -0700 Subject: [PATCH] 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. --- src/win32_replacements.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: -- 2.43.0