]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-145301: Fix double-free in hashlib initialization (GH-145321) (GH-145532)
authorkrylosov-aa <krylosov.andrew@gmail.com>
Tue, 10 Mar 2026 13:59:37 +0000 (16:59 +0300)
committerGitHub <noreply@github.com>
Tue, 10 Mar 2026 13:59:37 +0000 (14:59 +0100)
(cherry picked from commit 6acaf659ef0fdee131bc02f0b58685da039b5855)

Misc/NEWS.d/next/Library/2026-02-27-19-00-26.gh-issue-145301.2Wih4b.rst [new file with mode: 0644]
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 (file)
index 0000000..7aeb6a1
--- /dev/null
@@ -0,0 +1,2 @@
+:mod:`hashlib`: fix a crash when the initialization of the underlying C
+extension module fails.
index 5e4783395f4f48306665e50b35b51acd99349a88..bf3894e4ffbea991479da064f9dd2cbb2b62db1a 100644 (file)
@@ -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++;