From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 8 May 2025 11:36:38 +0000 (+0200) Subject: gh-133597: Fix memory leak if error occurred in _sys_getwindowsversion_from_kernel32... X-Git-Tag: v3.14.0b2~230 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=caeb422cbca5a4470d406b52f3a712305214982e;p=thirdparty%2FPython%2Fcpython.git gh-133597: Fix memory leak if error occurred in _sys_getwindowsversion_from_kernel32 (GH-133598) (cherry picked from commit 0ec8fc83a83914d2ae97e52529e98ce63aaf831c) Co-authored-by: Sergey Miryanov --- diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 00dce4527fbb..41b9a6b276a3 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; }