From 0ec8fc83a83914d2ae97e52529e98ce63aaf831c Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Thu, 8 May 2025 04:09:20 -0700 Subject: gh-133597: Fix memory leak if error occurred in _sys_getwindowsversion_from_kernel32 (GH-133598) --- Python/sysmodule.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Python') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 00dce4527fb..41b9a6b276a 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1670,6 +1670,9 @@ _sys_getwindowsversion_from_kernel32(void) !GetFileVersionInfoW(kernel32_path, 0, verblock_size, verblock) || !VerQueryValueW(verblock, L"", (LPVOID)&ffi, &ffi_len)) { PyErr_SetFromWindowsErr(0); + if (verblock) { + PyMem_RawFree(verblock); + } return NULL; } -- cgit v1.2.3