Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 39105:aa85791f5991 legacy-trunk
Reported by Klocwork #151.
v2 can be NULL if exception2 is NULL. I don't think that condition can happen,
but I'm not sure it can't either. Now the code will protect against either
being NULL.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Mon, 17 Jul 2006 00:59:04 +0000 |
| parents | 42808526511c |
| children | 7c09b66f04bd |
comparison
equal
deleted
inserted
replaced
| 39104:6064cb301209 | 39105:aa85791f5991 |
|---|---|
| 1062 if (PyErr_ExceptionMatches(PyExc_SystemExit)) { | 1062 if (PyErr_ExceptionMatches(PyExc_SystemExit)) { |
| 1063 handle_system_exit(); | 1063 handle_system_exit(); |
| 1064 } | 1064 } |
| 1065 PyErr_Fetch(&exception2, &v2, &tb2); | 1065 PyErr_Fetch(&exception2, &v2, &tb2); |
| 1066 PyErr_NormalizeException(&exception2, &v2, &tb2); | 1066 PyErr_NormalizeException(&exception2, &v2, &tb2); |
| 1067 /* It should not be possible for exception2 or v2 | |
| 1068 to be NULL. However PyErr_Display() can't | |
| 1069 tolerate NULLs, so just be safe. */ | |
| 1070 if (exception2 == NULL) { | |
| 1071 exception2 = Py_None; | |
| 1072 Py_INCREF(exception2); | |
| 1073 } | |
| 1074 if (v2 == NULL) { | |
| 1075 v2 = Py_None; | |
| 1076 Py_INCREF(v2); | |
| 1077 } | |
| 1067 if (Py_FlushLine()) | 1078 if (Py_FlushLine()) |
| 1068 PyErr_Clear(); | 1079 PyErr_Clear(); |
| 1069 fflush(stdout); | 1080 fflush(stdout); |
| 1070 PySys_WriteStderr("Error in sys.excepthook:\n"); | 1081 PySys_WriteStderr("Error in sys.excepthook:\n"); |
| 1071 PyErr_Display(exception2, v2, tb2); | 1082 PyErr_Display(exception2, v2, tb2); |
| 1072 PySys_WriteStderr("\nOriginal exception was:\n"); | 1083 PySys_WriteStderr("\nOriginal exception was:\n"); |
| 1073 PyErr_Display(exception, v, tb); | 1084 PyErr_Display(exception, v, tb); |
| 1074 Py_XDECREF(exception2); | 1085 Py_DECREF(exception2); |
| 1075 Py_XDECREF(v2); | 1086 Py_DECREF(v2); |
| 1076 Py_XDECREF(tb2); | 1087 Py_XDECREF(tb2); |
| 1077 } | 1088 } |
| 1078 Py_XDECREF(result); | 1089 Py_XDECREF(result); |
| 1079 Py_XDECREF(args); | 1090 Py_XDECREF(args); |
| 1080 } else { | 1091 } else { |
