Skip to content

Commit 0c8c442

Browse files
committed
[3.13] gh-145301: Fix double-free in hashlib and hmac module initialization (GH-145321)
(cherry picked from commit 6acaf65) Co-authored-by: krylosov-aa <krylosov.andrew@gmail.com> gh-145301: Fix double-free in hashlib and hmac initialization
1 parent 482d6f8 commit 0c8c442

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:mod:`hashlib`: fix a crash when the initialization of the underlying C
2+
extension module fails.

Modules/_hashopenssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ py_hashentry_table_new(void) {
239239

240240
if (h->py_alias != NULL) {
241241
if (_Py_hashtable_set(ht, (const void*)entry->py_alias, (void*)entry) < 0) {
242-
PyMem_Free(entry);
242+
/* entry is already in ht, will be freed by _Py_hashtable_destroy() */
243243
goto error;
244244
}
245245
entry->refcnt++;

0 commit comments

Comments
 (0)