diff options
author | Hye-Shik Chang <hyeshik@gmail.com> | 2006-03-07 15:39:21 (GMT) |
---|---|---|
committer | Hye-Shik Chang <hyeshik@gmail.com> | 2006-03-07 15:39:21 (GMT) |
commit | 4af5c8cee4885df70884a58e2e74c48984bbe7c2 (patch) | |
tree | f4c33e559962940576f84b61f760a1b27a3b8618 /Python | |
parent | ef1701f7d3a57427c1289bef32227a7aaac7905a (diff) | |
download | cpython-4af5c8cee4885df70884a58e2e74c48984bbe7c2.zip cpython-4af5c8cee4885df70884a58e2e74c48984bbe7c2.tar.gz cpython-4af5c8cee4885df70884a58e2e74c48984bbe7c2.tar.bz2 |
SF #1444030: Fix several potential defects found by Coverity.
(reviewed by Neal Norwitz)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ast.c | 2 | ||||
-rw-r--r-- | Python/ceval.c | 5 | ||||
-rw-r--r-- | Python/traceback.c | 6 |
3 files changed, 11 insertions, 2 deletions
diff --git a/Python/ast.c b/Python/ast.c index 5fbea39..bb1774b 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -1438,6 +1438,8 @@ ast_for_trailer(struct compiling *c, const node *n, expr_ty left_expr) } /* extract Index values and put them in a Tuple */ elts = asdl_seq_new(asdl_seq_LEN(slices), c->c_arena); + if (!elts) + return NULL; for (j = 0; j < asdl_seq_LEN(slices); ++j) { slc = (slice_ty)asdl_seq_GET(slices, j); assert(slc->kind == Index_kind && slc->v.Index.value); diff --git a/Python/ceval.c b/Python/ceval.c index 5fda826..b069c77 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3477,8 +3477,11 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; - if (arg == NULL) + if (arg == NULL) { arg = PyTuple_New(0); + if (arg == NULL) + return NULL; + } else if (!PyTuple_Check(arg)) { PyErr_SetString(PyExc_TypeError, "argument list must be a tuple"); diff --git a/Python/traceback.c b/Python/traceback.c index 7b83d8b..6c11cf5 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -185,8 +185,12 @@ tb_displayline(PyObject *f, char *filename, int lineno, char *name) } PyOS_snprintf(linebuf, sizeof(linebuf), FMT, filename, lineno, name); err = PyFile_WriteString(linebuf, f); - if (xfp == NULL || err != 0) + if (xfp == NULL) return err; + else if (err != 0) { + fclose(xfp); + return err; + } for (i = 0; i < lineno; i++) { char* pLastChar = &linebuf[sizeof(linebuf)-2]; do { |