Skip to content

Commit 3b1aa5f

Browse files
committed
gh-145376: Fix crashes in md5module.c
Fix a possible NULL pointer dereference in `md5module.c`. This can only occur in error paths taken when the interpreter fails to allocate memory. (cherry-picked from c1d7768)
1 parent 5db0177 commit 3b1aa5f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Modules/md5module.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ MD5_traverse(PyObject *ptr, visitproc visit, void *arg)
8484
static void
8585
MD5_dealloc(MD5object *ptr)
8686
{
87-
Hacl_Hash_MD5_free(ptr->hash_state);
87+
if (ptr->hash_state != NULL) {
88+
Hacl_Hash_MD5_free(ptr->hash_state);
89+
ptr->hash_state == NULL;
90+
}
8891
PyTypeObject *tp = Py_TYPE((PyObject*)ptr);
8992
PyObject_GC_UnTrack(ptr);
9093
PyObject_GC_Del(ptr);

0 commit comments

Comments
 (0)