* 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
c1d77683213c400fca144692654845e6f5418981)
* 📜🤖 Added by blurb_it.
* Update Modules/md5module.c
---------
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
--- /dev/null
+Fix null pointer dereference in unusual error scenario in :mod:`hashlib`.
static void
MD5_dealloc(MD5object *ptr)
{
- Hacl_Hash_MD5_free(ptr->hash_state);
+ if (ptr->hash_state != NULL) {
+ Hacl_Hash_MD5_free(ptr->hash_state);
+ ptr->hash_state = NULL;
+ }
PyTypeObject *tp = Py_TYPE((PyObject*)ptr);
PyObject_GC_UnTrack(ptr);
PyObject_GC_Del(ptr);