bpo-37702: Fix SSL's certificate-store leak on Windows (GH-15632)

ssl_collect_certificates function in _ssl.c has a memory leak.
Calling CertOpenStore() and CertAddStoreToCollection(), a store's refcnt gets incremented by 2.
But CertCloseStore() is called only once and the refcnt leaves 1.
This commit is contained in:
neonene 2019-09-09 21:33:43 +09:00 committed by Steve Dower
parent b4612f5d54
commit ed70129e15
2 changed files with 3 additions and 0 deletions

View File

@ -0,0 +1,2 @@
Fix memory leak on Windows in creating an SSLContext object or
running urllib.request.urlopen('https://...').

View File

@ -5581,6 +5581,7 @@ ssl_collect_certificates(const char *store_name)
if (result) {
++storesAdded;
}
CertCloseStore(hSystemStore, 0); /* flag must be 0 */
}
}
if (storesAdded == 0) {