gh-145301: Fix double-free in hashlib and hmac module initialization … · python/cpython@6acaf65 · GitHub
Skip to content

Commit 6acaf65

Browse files
authored
gh-145301: Fix double-free in hashlib and hmac module initialization (GH-145321)
gh-145301: Fix double-free in hashlib and hmac initialization
1 parent 8b54313 commit 6acaf65

4 files changed

Lines changed: 18 additions & 11 deletions

File tree

Lines changed: 2 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:mod:`hmac`: 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
@@ -268,7 +268,7 @@ py_hashentry_table_new(void) {
268268

269269
if (h->py_alias != NULL) {
270270
if (_Py_hashtable_set(ht, (const void*)entry->py_alias, (void*)entry) < 0) {
271-
PyMem_Free(entry);
271+
/* entry is already in ht, will be freed by _Py_hashtable_destroy() */
272272
goto error;
273273
}
274274
entry->refcnt++;

Modules/hmacmodule.c

Lines changed: 13 additions & 10 deletions

0 commit comments

Comments
 (0)