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:
parent
2fdfadf6dd
commit
55087f0c35
|
@ -491,16 +491,15 @@ SHA_new(PyObject *self, PyObject *args, PyObject *kwdict)
|
||||||
SHAobject *new;
|
SHAobject *new;
|
||||||
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()) {
|
||||||
|
|
Loading…
Reference in New Issue