Cleanup logic a little. Check args first, then try to create the

object.  This avoids creation + decref if bogus arguments are passed.
This commit is contained in:
Jeremy Hylton 2001-01-29 22:46:35 +00:00
parent 2fdfadf6dd
commit 55087f0c35
1 changed files with 3 additions and 4 deletions

View File

@ -492,15 +492,14 @@ SHA_new(PyObject *self, PyObject *args, PyObject *kwdict)
unsigned char *cp = NULL; unsigned char *cp = NULL;
int len; int len;
if ((new = newSHAobject()) == NULL)
return NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist, if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist,
&cp, &len)) { &cp, &len)) {
Py_DECREF(new);
return NULL; return NULL;
} }
if ((new = newSHAobject()) == NULL)
return NULL;
sha_init(new); sha_init(new);
if (PyErr_Occurred()) { if (PyErr_Occurred()) {