]> granicus.if.org Git - python/commitdiff
Cleanup logic a little. Check args first, then try to create the
authorJeremy Hylton <jeremy@alum.mit.edu>
Mon, 29 Jan 2001 22:46:35 +0000 (22:46 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Mon, 29 Jan 2001 22:46:35 +0000 (22:46 +0000)
object.  This avoids creation + decref if bogus arguments are passed.

Modules/shamodule.c

index 32ac02dbabee40a7b9ceb063b08dbdd5353c08ee..8bfcec7b82b71db4cb144069410f7323c7c21168 100644 (file)
@@ -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()) {