From dc47a19e576dcb358547608c5347a6bf78ced562 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 2 May 2014 22:06:44 +0200 Subject: Issue #21393: random.c: on Windows, close the hCryptProv handle at exit --- Python/random.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Python/random.c') diff --git a/Python/random.c b/Python/random.c index 2941ba16af..b04d205a46 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 } -- cgit v1.2.1 From 0bb52d78d45567397897b61a0032b8dd5eb059c3 Mon Sep 17 00:00:00 2001 From: Tim Golden Date: Tue, 6 May 2014 13:29:45 +0100 Subject: Issue21393 Use CryptReleaseContext to release Crypt handle on Windows --- Python/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/random.c') diff --git a/Python/random.c b/Python/random.c index b04d205a46..a052b65725 100644 --- a/Python/random.c +++ b/Python/random.c @@ -298,7 +298,7 @@ _PyRandom_Fini(void) { #ifdef MS_WINDOWS if (hCryptProv) { - CloseHandle(hCryptProv); + CryptReleaseContext(hCryptProv, 0); hCryptProv = 0; } #else -- cgit v1.2.1