summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/md5module.c9
-rw-r--r--Modules/sha1module.c9
-rw-r--r--Modules/sha256module.c14
-rw-r--r--Modules/sha512module.c14
4 files changed, 38 insertions, 8 deletions
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 @@ MD5_new(PyObject *self, PyObject *args, PyObject *kwdict)
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;
diff --git a/Modules/sha1module.c b/Modules/sha1module.c
index a7f6ad2..3e630eb 100644
--- a/Modules/sha1module.c
+++ b/Modules/sha1module.c
@@ -502,18 +502,23 @@ SHA1_new(PyObject *self, PyObject *args, PyObject *kwdict)
if (data_obj)
GET_BUFFER_VIEW_OR_ERROUT(data_obj, &buf);
- if ((new = newSHA1object()) == NULL)
+ if ((new = newSHA1object()) == NULL) {
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
+ }
sha1_init(&new->hash_state);
if (PyErr_Occurred()) {
Py_DECREF(new);
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
}
if (data_obj) {
sha1_process(&new->hash_state, buf.buf, buf.len);
- PyBuffer_Release(&buf);
+ PyBuffer_Release(&buf);
}
return (PyObject *)new;
diff --git a/Modules/sha256module.c b/Modules/sha256module.c
index c653416..7c9b58d 100644
--- a/Modules/sha256module.c
+++ b/Modules/sha256module.c
@@ -629,13 +629,18 @@ SHA256_new(PyObject *self, PyObject *args, PyObject *kwdict)
if (data_obj)
GET_BUFFER_VIEW_OR_ERROUT(data_obj, &buf);
- if ((new = newSHA256object()) == NULL)
+ if ((new = newSHA256object()) == NULL) {
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
+ }
sha_init(new);
if (PyErr_Occurred()) {
Py_DECREF(new);
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
}
if (data_obj) {
@@ -665,13 +670,18 @@ SHA224_new(PyObject *self, PyObject *args, PyObject *kwdict)
if (data_obj)
GET_BUFFER_VIEW_OR_ERROUT(data_obj, &buf);
- if ((new = newSHA224object()) == NULL)
+ if ((new = newSHA224object()) == NULL) {
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
+ }
sha224_init(new);
if (PyErr_Occurred()) {
Py_DECREF(new);
+ if (data_obj)
+ PyBuffer_Release(&buf);
return NULL;
}
if (data_obj) {
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) {