]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #21393: random.c: on Windows, close the hCryptProv handle at exit
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 2 May 2014 20:06:44 +0000 (22:06 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 2 May 2014 20:06:44 +0000 (22:06 +0200)
Python/random.c

index 2941ba16af0697c9d82b00d75a36c2c61a8e3ea8..b04d205a46fe566d8b2911ec2074ee5d576e9f9d 100644 (file)
@@ -15,8 +15,6 @@ static int _Py_HashSecret_Initialized = 0;
 #endif
 
 #ifdef MS_WINDOWS
-/* This handle is never explicitly released. Instead, the operating
-   system will release it when the process terminates. */
 static HCRYPTPROV hCryptProv = 0;
 
 static int
@@ -298,7 +296,12 @@ _PyRandom_Init(void)
 void
 _PyRandom_Fini(void)
 {
-#ifndef MS_WINDOWS
+#ifdef MS_WINDOWS
+    if (hCryptProv) {
+        CloseHandle(hCryptProv);
+        hCryptProv = 0;
+    }
+#else
     dev_urandom_close();
 #endif
 }