mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-35983: skip trashcan for subclasses (GH-11841)
Add new trashcan macros to deal with a double deallocation that could occur when the `tp_dealloc` of a subclass calls the `tp_dealloc` of a base class and that base class uses the trashcan mechanism. Patch by Jeroen Demeyer.
This commit is contained in:
parent
a2fedd8c91
commit
351c67416b
15 changed files with 189 additions and 121 deletions
|
@ -559,7 +559,7 @@ set_dealloc(PySetObject *so)
|
|||
|
||||
/* bpo-31095: UnTrack is needed before calling any callbacks */
|
||||
PyObject_GC_UnTrack(so);
|
||||
Py_TRASHCAN_SAFE_BEGIN(so)
|
||||
Py_TRASHCAN_BEGIN(so, set_dealloc)
|
||||
if (so->weakreflist != NULL)
|
||||
PyObject_ClearWeakRefs((PyObject *) so);
|
||||
|
||||
|
@ -572,7 +572,7 @@ set_dealloc(PySetObject *so)
|
|||
if (so->table != so->smalltable)
|
||||
PyMem_DEL(so->table);
|
||||
Py_TYPE(so)->tp_free(so);
|
||||
Py_TRASHCAN_SAFE_END(so)
|
||||
Py_TRASHCAN_END
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue