mirror of
https://github.com/python/cpython.git
synced 2025-08-15 22:30:42 +00:00
The _lsprof module could crash the interpreter if it was given an external
timer that did not return a float and a timer was still running when the Profiler object was garbage collected. Fixes issue 3895. Code review by Benjamin Peterson.
This commit is contained in:
parent
09c0178242
commit
b2d61bde28
3 changed files with 29 additions and 2 deletions
|
@ -150,7 +150,16 @@ static PY_LONG_LONG CallExternalTimer(ProfilerObject *pObj)
|
|||
}
|
||||
Py_DECREF(o);
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_WriteUnraisable((PyObject *) pObj);
|
||||
PyObject *context = (PyObject *)pObj;
|
||||
/* May have been called by profiler_dealloc(). */
|
||||
if (Py_REFCNT(context) < 1) {
|
||||
context = PyString_FromString("profiler calling an "
|
||||
"external timer");
|
||||
if (context == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
PyErr_WriteUnraisable(context);
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue