diff options
author | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-03-03 07:49:01 (GMT) |
---|---|---|
committer | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-03-03 07:49:01 (GMT) |
commit | 8404749e4b65f23a7d84c3940ea061eee0b4b344 (patch) | |
tree | d8082d486912a2af4485d4b47dceee81bc6a3f02 /Modules/sha512module.c | |
parent | 45ed72ddaf16c97237f2ad522959d6ffd8b40e2e (diff) | |
download | cpython-8404749e4b65f23a7d84c3940ea061eee0b4b344.zip cpython-8404749e4b65f23a7d84c3940ea061eee0b4b344.tar.gz cpython-8404749e4b65f23a7d84c3940ea061eee0b4b344.tar.bz2 |
Fixed memory leak on failure. This is related to issue5403 but won't crash on py3k.
Diffstat (limited to 'Modules/sha512module.c')
-rw-r--r-- | Modules/sha512module.c | 14 |
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) { |