PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste

bug in both:  `className` was referenced before being checked for NULL.
This commit is contained in:
Tim Peters 2006-05-28 10:41:29 +00:00
parent a37722cc42
commit 5e9d6cfbda
2 changed files with 23 additions and 18 deletions

View File

@ -588,13 +588,16 @@ PyErr_WriteUnraisable(PyObject *obj)
if (f != NULL) {
PyFile_WriteString("Exception ", f);
if (t) {
char* className = PyExceptionClass_Name(t);
PyObject* moduleName;
char *dot = strrchr(className, '.');
if (dot != NULL)
className = dot+1;
moduleName = PyObject_GetAttrString(t, "__module__");
char* className = PyExceptionClass_Name(t);
if (className != NULL) {
char *dot = strrchr(className, '.');
if (dot != NULL)
className = dot+1;
}
moduleName = PyObject_GetAttrString(t, "__module__");
if (moduleName == NULL)
PyFile_WriteString("<unknown>", f);
else {

View File

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