Mercurial > cpython-lru_cache-weakref
diff Python/modsupport.c @ 36858:7fac5d79d043 legacy-trunk
Try to cleanup the error handling a bit so there aren't false positives
from static analysis. v was already checked for NULL above, so we don't
need a second check.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Mon, 06 Mar 2006 23:07:34 +0000 |
| parents | 35612a131ac6 |
| children | 03894a7a32ec f731859e9b3b |
line wrap: on
line diff
--- a/Python/modsupport.c Mon Mar 06 23:04:04 2006 +0000 +++ b/Python/modsupport.c Mon Mar 06 23:07:34 2006 +0000 @@ -206,7 +206,8 @@ 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 @@ } PyList_SetItem(v, i, w); } - if (v != NULL && **p_format != endchar) { + + if (itemfailed) { + /* do_mkvalue() should have already set an error */ Py_DECREF(v); - v = NULL; + return NULL; + } + if (**p_format != endchar) { + Py_DECREF(v); 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; }
