Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55087f0

Browse files
committed
Cleanup logic a little. Check args first, then try to create the
object. This avoids creation + decref if bogus arguments are passed.
1 parent 2fdfadf commit 55087f0

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Modules/shamodule.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,16 +491,15 @@ SHA_new(PyObject *self, PyObject *args, PyObject *kwdict)
491491
SHAobject *new;
492492
unsigned char *cp = NULL;
493493
int len;
494-
495-
if ((new = newSHAobject()) == NULL)
496-
return NULL;
497494

498495
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s#:new", kwlist,
499496
&cp, &len)) {
500-
Py_DECREF(new);
501497
return NULL;
502498
}
503499

500+
if ((new = newSHAobject()) == NULL)
501+
return NULL;
502+
504503
sha_init(new);
505504

506505
if (PyErr_Occurred()) {

0 commit comments

Comments
 (0)