summaryrefslogtreecommitdiffstats
path: root/Modules/sha512module.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/sha512module.c')
-rw-r--r--Modules/sha512module.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/Modules/sha512module.c b/Modules/sha512module.c
index 17e417e..387187f 100644
--- a/Modules/sha512module.c
+++ b/Modules/sha512module.c
@@ -695,13 +695,18 @@ SHA512_new(PyObject *self, PyObject *args, PyObject *kwdict)
if (data_obj)
GET_BUFFER_VIEW_OR_ERROUT(data_obj, &buf);
- if ((new = newSHA512object()) == NULL)
+ if ((new = newSHA512object()) == NULL) {
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
+ }
sha512_init(new);
if (PyErr_Occurred()) {
Py_DECREF(new);
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
}
if (data_obj) {
@@ -731,13 +736,18 @@ SHA384_new(PyObject *self, PyObject *args, PyObject *kwdict)
if (data_obj)
GET_BUFFER_VIEW_OR_ERROUT(data_obj, &buf);
- if ((new = newSHA384object()) == NULL)
+ if ((new = newSHA384object()) == NULL) {
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
+ }
sha384_init(new);
if (PyErr_Occurred()) {
Py_DECREF(new);
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
}
if (data_obj) {