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:32:59 +02:00 committed by GitHub
parent a719e5fbb6
commit e0aefbd263
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

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