Skip to content

Commit ed70129

Browse files
neonenezooba
authored andcommitted
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.
1 parent b4612f5 commit ed70129

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix memory leak on Windows in creating an SSLContext object or
2+
running urllib.request.urlopen('https://...').

Modules/_ssl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5581,6 +5581,7 @@ ssl_collect_certificates(const char *store_name)
55815581
if (result) {
55825582
++storesAdded;
55835583
}
5584+
CertCloseStore(hSystemStore, 0); /* flag must be 0 */
55845585
}
55855586
}
55865587
if (storesAdded == 0) {

0 commit comments

Comments
 (0)