summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-05-02 20:06:44 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-05-02 20:06:44 (GMT)
commitd50c3f3f3af54f3be46d26d53a1c10b7c15a7b2d (patch)
treedab22e5cd3bdee3e0a9acadc2f8a7415b3717511 /Python
parentcb2ad801ac2bbee4f72c935e7fa57cc5b50382f2 (diff)
downloadcpython-d50c3f3f3af54f3be46d26d53a1c10b7c15a7b2d.zip
cpython-d50c3f3f3af54f3be46d26d53a1c10b7c15a7b2d.tar.gz
cpython-d50c3f3f3af54f3be46d26d53a1c10b7c15a7b2d.tar.bz2
Issue #21393: random.c: on Windows, close the hCryptProv handle at exit
Diffstat (limited to 'Python')
-rw-r--r--Python/random.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Python/random.c b/Python/random.c
index 2941ba1..b04d205 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -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
}