]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133597: Fix memory leak if error occurred in _sys_getwindowsversion_from_kernel32...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 8 May 2025 11:36:38 +0000 (13:36 +0200)
committerGitHub <noreply@github.com>
Thu, 8 May 2025 11:36:38 +0000 (11:36 +0000)
(cherry picked from commit 0ec8fc83a83914d2ae97e52529e98ce63aaf831c)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Python/sysmodule.c

index 00dce4527fbb90d634e9cf31522819ca8bd0bdea..41b9a6b276a3b1ae2e347bc3606798d3ffc5bfca 100644 (file)
@@ -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;
     }