Skip to content

Commit 472f37a

Browse files
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. (cherry picked from commit ed70129) Co-authored-by: neonene <[email protected]>
1 parent 64f7f6e commit 472f37a

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
@@ -5448,6 +5448,7 @@ ssl_collect_certificates(const char *store_name)
54485448
if (result) {
54495449
++storesAdded;
54505450
}
5451+
CertCloseStore(hSystemStore, 0); /* flag must be 0 */
54515452
}
54525453
}
54535454
if (storesAdded == 0) {

0 commit comments

Comments
 (0)