]> granicus.if.org Git - python/commitdiff
Try to cleanup the error handling a bit so there aren't false positives
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 6 Mar 2006 23:07:34 +0000 (23:07 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 6 Mar 2006 23:07:34 +0000 (23:07 +0000)
from static analysis.  v was already checked for NULL above, so we don't
need a second check.

Python/modsupport.c

index f53e4c362ee8bebaa0be3f69dc15b543b244fb6a..cb6bdfd2853fd71380d613955c7dcd3f1ab7e0d6 100644 (file)
@@ -206,7 +206,8 @@ do_mklist(const char **p_format, va_list *p_va, int endchar, int n)
        int itemfailed = 0;
        if (n < 0)
                return NULL;
-       if ((v = PyList_New(n)) == NULL)
+       v = PyList_New(n);
+       if (v == NULL)
                return NULL;
        /* Note that we can't bail immediately on error as this will leak
           refcounts on any 'N' arguments. */
@@ -219,18 +220,21 @@ do_mklist(const char **p_format, va_list *p_va, int endchar, int n)
                }
                PyList_SetItem(v, i, w);
        }
-       if (v != NULL && **p_format != endchar) {
+
+       if (itemfailed) {
+               /* do_mkvalue() should have already set an error */
+               Py_DECREF(v);
+               return NULL;
+       }
+       if (**p_format != endchar) {
                Py_DECREF(v);
-               v = NULL;
                PyErr_SetString(PyExc_SystemError,
                                "Unmatched paren in format");
+               return NULL;
        }
-       else if (endchar)
+
+       if (endchar)
                ++*p_format;
-       if (itemfailed) {
-               Py_DECREF(v);
-               v = NULL;
-       }
        return v;
 }