mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Issue #21393: random.c: on Windows, close the hCryptProv handle at exit
This commit is contained in:
parent
cb2ad801ac
commit
d50c3f3f3a
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue