diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-01-29 22:46:35 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-01-29 22:46:35 (GMT) |
commit | 55087f0c351d6de453a5c95293792051d899f16b (patch) | |
tree | ece917fd15c87c96d466be0c937021904f977199 | |
parent | 2fdfadf6dd796c0a9a467c8800eaa501b0407908 (diff) | |
download | cpython-55087f0c351d6de453a5c95293792051d899f16b.zip cpython-55087f0c351d6de453a5c95293792051d899f16b.tar.gz cpython-55087f0c351d6de453a5c95293792051d899f16b.tar.bz2 |
Cleanup logic a little. Check args first, then try to create the
object. This avoids creation + decref if bogus arguments are passed.
-rw-r--r-- | Modules/shamodule.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Modules/shamodule.c b/Modules/shamodule.c index 32ac02d..8bfcec7 100644 --- a/Modules/shamodule.c +++ b/Modules/shamodule.c @@ -491,16 +491,15 @@ SHA_new(PyObject *self, PyObject *args, PyObject *kwdict) SHAobject *new; unsigned char *cp = NULL; int len; - - if ((new = newSHAobject()) == NULL) - return NULL; if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist, &cp, &len)) { - Py_DECREF(new); return NULL; } + if ((new = newSHAobject()) == NULL) + return NULL; + sha_init(new); if (PyErr_Occurred()) { |