mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
bpo-33930: Fix segfault with deep recursion when cleaning method objects (GH-27678)
This commit is contained in:
parent
c0ab59f7de
commit
bfc2d5a5c4
3 changed files with 22 additions and 1 deletions
|
@ -160,7 +160,10 @@ PyCMethod_GetClass(PyObject *op)
|
|||
static void
|
||||
meth_dealloc(PyCFunctionObject *m)
|
||||
{
|
||||
_PyObject_GC_UNTRACK(m);
|
||||
// The Py_TRASHCAN mechanism requires that we be able to
|
||||
// call PyObject_GC_UnTrack twice on an object.
|
||||
PyObject_GC_UnTrack(m);
|
||||
Py_TRASHCAN_BEGIN(m, meth_dealloc);
|
||||
if (m->m_weakreflist != NULL) {
|
||||
PyObject_ClearWeakRefs((PyObject*) m);
|
||||
}
|
||||
|
@ -170,6 +173,7 @@ meth_dealloc(PyCFunctionObject *m)
|
|||
Py_XDECREF(m->m_self);
|
||||
Py_XDECREF(m->m_module);
|
||||
PyObject_GC_Del(m);
|
||||
Py_TRASHCAN_END;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue