diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-08-11 08:32:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 08:32:44 (GMT) |
commit | d6d2d549972422ccc6fa335ebf9907e4b3d71817 (patch) | |
tree | b6660f67cd8788c974a5510e9e982670c6c1789e /Objects | |
parent | a6808c6378ccfd732285ee20319658ac29eacf4c (diff) | |
download | cpython-d6d2d549972422ccc6fa335ebf9907e4b3d71817.zip cpython-d6d2d549972422ccc6fa335ebf9907e4b3d71817.tar.gz cpython-d6d2d549972422ccc6fa335ebf9907e4b3d71817.tar.bz2 |
bpo-33930: Fix segfault with deep recursion when cleaning method objects (GH-27678) (GH-27719)
(cherry picked from commit bfc2d5a5c4550ab3a2fadeb9459b4bd948ff61a2)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/methodobject.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c index 7b43041..2df63cf 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -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 * |