mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +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
|
@ -240,7 +240,7 @@ tupledealloc(PyTupleObject *op)
|
|||
Py_ssize_t i;
|
||||
Py_ssize_t len = Py_SIZE(op);
|
||||
PyObject_GC_UnTrack(op);
|
||||
Py_TRASHCAN_SAFE_BEGIN(op)
|
||||
Py_TRASHCAN_BEGIN(op, tupledealloc)
|
||||
if (len > 0) {
|
||||
i = len;
|
||||
while (--i >= 0)
|
||||
|
@ -259,7 +259,7 @@ tupledealloc(PyTupleObject *op)
|
|||
}
|
||||
Py_TYPE(op)->tp_free((PyObject *)op);
|
||||
done:
|
||||
Py_TRASHCAN_SAFE_END(op)
|
||||
Py_TRASHCAN_END
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue