]> granicus.if.org Git - python/commitdiff
Issue #27932: Prevent memory leak in win32_ver().
authorSteve Dower <steve.dower@microsoft.com>
Sat, 17 Sep 2016 23:43:01 +0000 (16:43 -0700)
committerSteve Dower <steve.dower@microsoft.com>
Sat, 17 Sep 2016 23:43:01 +0000 (16:43 -0700)
Lib/platform.py
Misc/NEWS

index 6e264f1ade2c337246df065f3cdc8a6e3d616a77..37dfbeea92548f49df580ab5e3bcf2bd867f93da 100755 (executable)
@@ -567,7 +567,7 @@ def _get_real_winver(maj, min, build):
         return maj, min, build
 
     from ctypes import (c_buffer, POINTER, byref, create_unicode_buffer,
-                        Structure, WinDLL)
+                        Structure, WinDLL, _Pointer)
     from ctypes.wintypes import DWORD, HANDLE
 
     class VS_FIXEDFILEINFO(Structure):
@@ -586,6 +586,8 @@ def _get_real_winver(maj, min, build):
             ("dwFileDateMS", DWORD),
             ("dwFileDateLS", DWORD),
         ]
+    class PVS_FIXEDFILEINFO(_Pointer):
+        _type_ = VS_FIXEDFILEINFO
 
     kernel32 = WinDLL('kernel32')
     version = WinDLL('version')
@@ -611,7 +613,7 @@ def _get_real_winver(maj, min, build):
         not ver_block):
         return maj, min, build
 
-    pvi = POINTER(VS_FIXEDFILEINFO)()
+    pvi = PVS_FIXEDFILEINFO()
     if not version.VerQueryValueW(ver_block, "", byref(pvi), byref(DWORD())):
         return maj, min, build
 
index 3638a1672a2753adf33ac553c2afdcfa3ff089b9..9ef88bf07b5ca0ba6f657b375fd42379dd2ba6ac 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -214,6 +214,8 @@ Tools/Demos
 Windows
 -------
 
+- Issue #27932: Prevent memory leak in win32_ver().
+
 - Issue #27888: Prevent Windows installer from displaying console windows and
   failing when pip cannot be installed/uninstalled.