diff options
author | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-03-03 22:05:57 (GMT) |
---|---|---|
committer | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-03-03 22:05:57 (GMT) |
commit | 8355155f2298ed5d45ae5381edaf953fceb06b14 (patch) | |
tree | 8a323b1e442aa50d8bb73fbf516cfb9d39eb94de /Modules | |
parent | 0b15541ae27fc926921ba1feb853c442a8ddaa82 (diff) | |
download | cpython-8355155f2298ed5d45ae5381edaf953fceb06b14.zip cpython-8355155f2298ed5d45ae5381edaf953fceb06b14.tar.gz cpython-8355155f2298ed5d45ae5381edaf953fceb06b14.tar.bz2 |
Fixed memory leak.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/sha256module.c | 14 | ||||
-rw-r--r-- | Modules/sha512module.c | 14 |
2 files changed, 24 insertions, 4 deletions
diff --git a/Modules/sha256module.c b/Modules/sha256module.c index e10ab9e..f489f48 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, NULL); - 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, NULL); - 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 5e606cb..2481275 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, NULL); - 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, NULL); - 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) { |