gh-133597: Fix memory leak if error occurred in _sys_getwindowsversion_from_kernel32 (GH-133598)

(cherry picked from commit 0ec8fc83a8)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-05-08 13:36:38 +02:00 committed by GitHub
parent 0f7046b187
commit caeb422cbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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;
}