summaryrefslogtreecommitdiffstats
path: root/Python/modsupport.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-03-06 23:07:34 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-03-06 23:07:34 (GMT)
commit3e90fa5940f7086f8617038524fe108bd58d627a (patch)
treeb0eeca9e41a63621762acef184dc943a40861a11 /Python/modsupport.c
parent4dc4a8401a360137659df07cb6ecaef1be37af05 (diff)
downloadcpython-3e90fa5940f7086f8617038524fe108bd58d627a.zip
cpython-3e90fa5940f7086f8617038524fe108bd58d627a.tar.gz
cpython-3e90fa5940f7086f8617038524fe108bd58d627a.tar.bz2
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.
Diffstat (limited to 'Python/modsupport.c')
-rw-r--r--Python/modsupport.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index f53e4c3..cb6bdfd 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -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;
}