[Python-checkins] r52171 - python/branches/release24-maint/Python/pythonrun.c
andrew.kuchling
python-checkins at python.org
Thu Oct 5 20:57:55 CEST 2006
Author: andrew.kuchling
Date: Thu Oct 5 20:57:54 2006
New Revision: 52171
Modified:
python/branches/release24-maint/Python/pythonrun.c
Log:
[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.
Modified: python/branches/release24-maint/Python/pythonrun.c
==============================================================================
--- python/branches/release24-maint/Python/pythonrun.c (original)
+++ python/branches/release24-maint/Python/pythonrun.c Thu Oct 5 20:57:54 2006
@@ -1080,6 +1080,17 @@
}
PyErr_Fetch(&exception2, &v2, &tb2);
PyErr_NormalizeException(&exception2, &v2, &tb2);
+ /* It should not be possible for exception2 or v2
+ to be NULL. However PyErr_Display() can't
+ tolerate NULLs, so just be safe. */
+ if (exception2 == NULL) {
+ exception2 = Py_None;
+ Py_INCREF(exception2);
+ }
+ if (v2 == NULL) {
+ v2 = Py_None;
+ Py_INCREF(v2);
+ }
if (Py_FlushLine())
PyErr_Clear();
fflush(stdout);
@@ -1087,8 +1098,8 @@
PyErr_Display(exception2, v2, tb2);
PySys_WriteStderr("\nOriginal exception was:\n");
PyErr_Display(exception, v, tb);
- Py_XDECREF(exception2);
- Py_XDECREF(v2);
+ Py_DECREF(exception2);
+ Py_DECREF(v2);
Py_XDECREF(tb2);
}
Py_XDECREF(result);
More information about the Python-checkins
mailing list