diff options
author | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2009-03-03 03:20:42 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2009-03-03 03:20:42 (GMT) |
commit | 7705d0aaafb6b034e9a3582e57f77d8f9cb5aa91 (patch) | |
tree | 3e75fadc1393ecf69f39ef7f032bd99127d6b065 /Modules/shamodule.c | |
parent | 7d49bba969a6ca490ade6aa908e350d3c05f76f4 (diff) | |
download | cpython-7705d0aaafb6b034e9a3582e57f77d8f9cb5aa91.zip cpython-7705d0aaafb6b034e9a3582e57f77d8f9cb5aa91.tar.gz cpython-7705d0aaafb6b034e9a3582e57f77d8f9cb5aa91.tar.bz2 |
Fix SHA_new and MD5_new, that would crash if not given initial data
Diffstat (limited to 'Modules/shamodule.c')
-rw-r--r-- | Modules/shamodule.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Modules/shamodule.c b/Modules/shamodule.c index e89a1ea..6399b75 100644 --- a/Modules/shamodule.c +++ b/Modules/shamodule.c @@ -548,10 +548,12 @@ SHA_new(PyObject *self, PyObject *args, PyObject *kwdict) return NULL; } - GET_BUFFER_VIEW_OR_ERROUT(data_obj, &view, NULL); + if (data_obj) + GET_BUFFER_VIEW_OR_ERROUT(data_obj, &view, NULL); if ((new = newSHAobject()) == NULL) { - PyBuffer_Release(&view); + if (data_obj) + PyBuffer_Release(&view); return NULL; } @@ -559,15 +561,16 @@ SHA_new(PyObject *self, PyObject *args, PyObject *kwdict) if (PyErr_Occurred()) { Py_DECREF(new); - PyBuffer_Release(&view); + if (data_obj) + PyBuffer_Release(&view); return NULL; } if (data_obj) { sha_update(new, (unsigned char*)view.buf, Py_SAFE_DOWNCAST(view.len, Py_ssize_t, unsigned int)); + PyBuffer_Release(&view); } - PyBuffer_Release(&view); return (PyObject *)new; } |