Fixed memory leak on failure. This is related to issue5403 but won't crash on py3k.
diff --git a/Modules/md5module.c b/Modules/md5module.c
index ac98433..6476bb7 100644
--- a/Modules/md5module.c
+++ b/Modules/md5module.c
@@ -526,18 +526,23 @@
if (data_obj)
GET_BUFFER_VIEW_OR_ERROUT(data_obj, &buf);
- if ((new = newMD5object()) == NULL)
+ if ((new = newMD5object()) == NULL) {
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
+ }
md5_init(&new->hash_state);
if (PyErr_Occurred()) {
Py_DECREF(new);
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
}
if (data_obj) {
md5_process(&new->hash_state, buf.buf, buf.len);
- PyBuffer_Release(&buf);
+ PyBuffer_Release(&buf);
}
return (PyObject *)new;