Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 40016:e65836815791 2.4
[Backport r50685 | neal.norwitz]
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 | Andrew M. Kuchling <amk@amk.ca> |
|---|---|
| date | Thu, 05 Oct 2006 18:57:54 +0000 |
| parents | 8c83fd79cee5 |
| children | 6860ba88d67e |
comparison
equal
deleted
inserted
replaced
| 40015:cd6ce666eff9 | 40016:e65836815791 |
|---|---|
| 1078 if (PyErr_ExceptionMatches(PyExc_SystemExit)) { | 1078 if (PyErr_ExceptionMatches(PyExc_SystemExit)) { |
| 1079 handle_system_exit(); | 1079 handle_system_exit(); |
| 1080 } | 1080 } |
| 1081 PyErr_Fetch(&exception2, &v2, &tb2); | 1081 PyErr_Fetch(&exception2, &v2, &tb2); |
| 1082 PyErr_NormalizeException(&exception2, &v2, &tb2); | 1082 PyErr_NormalizeException(&exception2, &v2, &tb2); |
| 1083 /* It should not be possible for exception2 or v2 | |
| 1084 to be NULL. However PyErr_Display() can't | |
| 1085 tolerate NULLs, so just be safe. */ | |
| 1086 if (exception2 == NULL) { | |
| 1087 exception2 = Py_None; | |
| 1088 Py_INCREF(exception2); | |
| 1089 } | |
| 1090 if (v2 == NULL) { | |
| 1091 v2 = Py_None; | |
| 1092 Py_INCREF(v2); | |
| 1093 } | |
| 1083 if (Py_FlushLine()) | 1094 if (Py_FlushLine()) |
| 1084 PyErr_Clear(); | 1095 PyErr_Clear(); |
| 1085 fflush(stdout); | 1096 fflush(stdout); |
| 1086 PySys_WriteStderr("Error in sys.excepthook:\n"); | 1097 PySys_WriteStderr("Error in sys.excepthook:\n"); |
| 1087 PyErr_Display(exception2, v2, tb2); | 1098 PyErr_Display(exception2, v2, tb2); |
| 1088 PySys_WriteStderr("\nOriginal exception was:\n"); | 1099 PySys_WriteStderr("\nOriginal exception was:\n"); |
| 1089 PyErr_Display(exception, v, tb); | 1100 PyErr_Display(exception, v, tb); |
| 1090 Py_XDECREF(exception2); | 1101 Py_DECREF(exception2); |
| 1091 Py_XDECREF(v2); | 1102 Py_DECREF(v2); |
| 1092 Py_XDECREF(tb2); | 1103 Py_XDECREF(tb2); |
| 1093 } | 1104 } |
| 1094 Py_XDECREF(result); | 1105 Py_XDECREF(result); |
| 1095 Py_XDECREF(args); | 1106 Py_XDECREF(args); |
| 1096 } else { | 1107 } else { |
