SF #1444030: Fix several potential defects found by Coverity.

(reviewed by Neal Norwitz)
This commit is contained in:
Hye-Shik Chang 2006-03-07 15:39:21 +00:00
parent ef1701f7d3
commit 4af5c8cee4
11 changed files with 53 additions and 17 deletions

View file

@ -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);

View file

@ -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");

View file

@ -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 {