Skip to content

Commit 157f397

Browse files
committed
gh-145301: Fix double-free in _hashlib module initialization
1 parent 98b1e51 commit 157f397

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a double-free bug in :mod:`_hashlib` module initialization when
2+
``_Py_hashtable_set()`` fails while adding an algorithm alias to the hash
3+
table after the primary name was already added

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++;

0 commit comments

Comments
 (0)