[Python-checkins] cpython (2.7): Issue #27932: Prevent memory leak in win32_ver().

steve.dower python-checkins at python.org
Sat Sep 17 19:43:51 EDT 2016


https://hg.python.org/cpython/rev/9b0d661a16de
changeset:   103905:9b0d661a16de
branch:      2.7
parent:      103874:a2bfec367cef
user:        Steve Dower <steve.dower at microsoft.com>
date:        Sat Sep 17 16:43:01 2016 -0700
summary:
  Issue #27932: Prevent memory leak in win32_ver().

files:
  Lib/platform.py |  6 ++++--
  Misc/NEWS       |  2 ++
  2 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Lib/platform.py b/Lib/platform.py
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -567,7 +567,7 @@
         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 @@
             ("dwFileDateMS", DWORD),
             ("dwFileDateLS", DWORD),
         ]
+    class PVS_FIXEDFILEINFO(_Pointer):
+        _type_ = VS_FIXEDFILEINFO
 
     kernel32 = WinDLL('kernel32')
     version = WinDLL('version')
@@ -611,7 +613,7 @@
         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
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -214,6 +214,8 @@
 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.
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list