diff options
author | Tim Peters <tim.peters@gmail.com> | 2006-05-28 10:41:29 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2006-05-28 10:41:29 (GMT) |
commit | 5e9d6cfbda8f968a849d5235b75b32e7175ad8fd (patch) | |
tree | a7a05e18789712e4ad961e98c8df0879b899c1cd /Python/pythonrun.c | |
parent | a37722cc423524ac9a35d6432cf3866d9a8d12bd (diff) | |
download | cpython-5e9d6cfbda8f968a849d5235b75b32e7175ad8fd.zip cpython-5e9d6cfbda8f968a849d5235b75b32e7175ad8fd.tar.gz cpython-5e9d6cfbda8f968a849d5235b75b32e7175ad8fd.tar.bz2 |
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 6f3ff6f..3a282e7 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -663,7 +663,7 @@ initsite(void) /* Parse input from a file and execute it */ int -PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, +PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags) { if (filename == NULL) @@ -744,7 +744,7 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags ps2 = PyString_AsString(w); } arena = PyArena_New(); - mod = PyParser_ASTFromFile(fp, filename, + mod = PyParser_ASTFromFile(fp, filename, Py_single_input, ps1, ps2, flags, &errcode, arena); Py_XDECREF(v); @@ -1132,13 +1132,15 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) /* Don't do anything else */ } else if (PyExceptionClass_Check(exception)) { - char* className = PyExceptionClass_Name(exception); - char *dot = strrchr(className, '.'); PyObject* moduleName; - if (dot != NULL) - className = dot+1; - moduleName = PyObject_GetAttrString(exception, "__module__"); + char* className = PyExceptionClass_Name(exception); + if (className != NULL) { + char *dot = strrchr(className, '.'); + if (dot != NULL) + className = dot+1; + } + moduleName = PyObject_GetAttrString(exception, "__module__"); if (moduleName == NULL) err = PyFile_WriteString("<unknown>", f); else { @@ -1184,7 +1186,7 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) } PyObject * -PyRun_StringFlags(const char *str, int start, PyObject *globals, +PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags) { PyObject *ret = NULL; @@ -1231,7 +1233,7 @@ run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals, } static PyObject * -run_pyc_file(FILE *fp, const char *filename, PyObject *globals, +run_pyc_file(FILE *fp, const char *filename, PyObject *globals, PyObject *locals, PyCompilerFlags *flags) { PyCodeObject *co; @@ -1300,13 +1302,13 @@ Py_SymtableString(const char *str, const char *filename, int start) /* Preferred access to parser is through AST. */ mod_ty -PyParser_ASTFromString(const char *s, const char *filename, int start, +PyParser_ASTFromString(const char *s, const char *filename, int start, PyCompilerFlags *flags, PyArena *arena) { mod_ty mod; perrdetail err; node *n = PyParser_ParseStringFlagsFilename(s, filename, - &_PyParser_Grammar, start, &err, + &_PyParser_Grammar, start, &err, PARSER_FLAGS(flags)); if (n) { mod = PyAST_FromNode(n, flags, filename, arena); @@ -1320,7 +1322,7 @@ PyParser_ASTFromString(const char *s, const char *filename, int start, } mod_ty -PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1, +PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1, char *ps2, PyCompilerFlags *flags, int *errcode, PyArena *arena) { @@ -1351,7 +1353,7 @@ PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int fla start, NULL, NULL, &err, flags); if (n == NULL) err_input(&err); - + return n; } |