Skip to content

Commit

Permalink
bpo-37702: Fix SSL's certificate-store leak on Windows (pythonGH-15632)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
neonene authored and zooba committed Sep 9, 2019
1 parent b4612f5 commit ed70129
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix memory leak on Windows in creating an SSLContext object or
running urllib.request.urlopen('https://...').
1 change: 1 addition & 0 deletions Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -5581,6 +5581,7 @@ ssl_collect_certificates(const char *store_name)
if (result) {
++storesAdded;
}
CertCloseStore(hSystemStore, 0); /* flag must be 0 */
}
}
if (storesAdded == 0) {
Expand Down

0 comments on commit ed70129

Please sign in to comment.