PATCH: Use FreeLibrary instead of CloseHandle to free Win32 DLL opened with LoadLibraryEx

John Thacker johnthacker at gmail.com
Sun May 10 16:29:17 CEST 2026


Below is a patch to fix an issue with a recent libgcrypt commit that
opens the Windows "shell32.dll" with LoadLibraryEx but closes it with
CloseHandle instead of the preferred FreeLibrary. This caused problems
running Wireshark under certain circumstances, e.g. under the MSVC
debugger.

Thanks,

John Thacker


>From 5979c49b981142efc2a0a8d67ee65fe62252dad7 Mon Sep 17 00:00:00
2001From: gpotter2 <10530980+gpotter2 at users.noreply.github.com>Date:
Thu, 7 May 2026 00:52:19 +0200Subject: [PATCH] Fix 'Invalid Handle'
crash on Win32--- src/hwfeatures.c | 2 +- 1 file changed, 1
insertion(+), 1 deletion(-)diff --git a/src/hwfeatures.c
b/src/hwfeatures.cindex 1b107e63..34017cf7 100644---
a/src/hwfeatures.c+++ b/src/hwfeatures.c@@ -336,7 +336,7 @@
_gcry_get_sysconfdir (void)               strcat (appdata,
"/GNU/etc/gcrypt/");             }           xfree (buf);-
CloseHandle (handle);+          FreeLibrary(handle);         }
if (!appdata)         appdata = xstrdup
("c:/ProgramData/GNU/etc/gcrypt/");--2.47.0.windows.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gcrypt-devel/attachments/20260510/26180645/attachment.html>


More information about the Gcrypt-devel mailing list