tccpe.c: fix msvcrt.dll handle leak on Windows ARM64

pe_get_process_msvcrt_handle() used LoadLibraryA which increments the
module reference count, but never called FreeLibrary to release it.

Use GetModuleHandleA instead, which returns a handle to the already-
loaded msvcrt.dll module without incrementing the reference count.
This is the correct API for accessing system DLLs that are already
mapped into the process address space.
This commit is contained in:
Benjamin Oldenburg 2026-03-20 16:42:21 +07:00
parent 4fb1e212c1
commit 6c5aac0da6

View File

@ -40,7 +40,7 @@ static HMODULE pe_get_process_msvcrt_handle(void)
wait_sem(&pe_msvcrt_sem);
dll = handle;
if (!dll) {
dll = LoadLibraryA("msvcrt.dll");
dll = GetModuleHandleA("msvcrt.dll");
if (dll)
handle = dll;
}