mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +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
|
|
@ -669,7 +669,7 @@ element_dealloc(ElementObject* self)
|
|||
{
|
||||
/* bpo-31095: UnTrack is needed before calling any callbacks */
|
||||
PyObject_GC_UnTrack(self);
|
||||
Py_TRASHCAN_SAFE_BEGIN(self)
|
||||
Py_TRASHCAN_BEGIN(self, element_dealloc)
|
||||
|
||||
if (self->weakreflist != NULL)
|
||||
PyObject_ClearWeakRefs((PyObject *) self);
|
||||
|
|
@ -680,7 +680,7 @@ element_dealloc(ElementObject* self)
|
|||
|
||||
RELEASE(sizeof(ElementObject), "destroy element");
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
Py_TRASHCAN_SAFE_END(self)
|
||||
Py_TRASHCAN_END
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue