]> 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:32:59 +0000 (13:32 +0200)
committerGitHub <noreply@github.com>
Thu, 8 May 2025 11:32:59 +0000 (11:32 +0000)
(cherry picked from commit 0ec8fc83a83914d2ae97e52529e98ce63aaf831c)

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

index 80d1bf3b914e37f87e052bbf314848609bae24c0..4b7f0cc68daadb5f460fbbfc3619d325e385e20b 100644 (file)
@@ -1693,6 +1693,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;
     }