https://github.com/python/cpython/commit/ba0d1b7deecf221597b2858c46fe6c4ff6f8417e
commit: ba0d1b7deecf221597b2858c46fe6c4ff6f8417e
branch: 3.13
author: krylosov-aa <[email protected]>
committer: encukou <[email protected]>
date: 2026-03-10T14:59:37+01:00
summary:

[3.13] gh-145301: Fix double-free in hashlib initialization (GH-145321) 
(GH-145532)

(cherry picked from commit 6acaf659ef0fdee131bc02f0b58685da039b5855)

files:
A Misc/NEWS.d/next/Library/2026-02-27-19-00-26.gh-issue-145301.2Wih4b.rst
M Modules/_hashopenssl.c

diff --git 
a/Misc/NEWS.d/next/Library/2026-02-27-19-00-26.gh-issue-145301.2Wih4b.rst 
b/Misc/NEWS.d/next/Library/2026-02-27-19-00-26.gh-issue-145301.2Wih4b.rst
new file mode 100644
index 00000000000000..7aeb6a1145ab4c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-02-27-19-00-26.gh-issue-145301.2Wih4b.rst
@@ -0,0 +1,2 @@
+:mod:`hashlib`: fix a crash when the initialization of the underlying C
+extension module fails.
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 5e4783395f4f48..bf3894e4ffbea9 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -239,7 +239,7 @@ py_hashentry_table_new(void) {
 
         if (h->py_alias != NULL) {
             if (_Py_hashtable_set(ht, (const void*)entry->py_alias, 
(void*)entry) < 0) {
-                PyMem_Free(entry);
+                /* entry is already in ht, will be freed by 
_Py_hashtable_destroy() */
                 goto error;
             }
             entry->refcnt++;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to