Fix error freeing bpy_struct sub-classes WITH_PYTHON_SECURITY enabled
Python's behavior changed since this feature was added causing the object to be tracked when freed by Python's subtype_dealloc even if Blender has not tracked the data. Detect this case and untrack the object before freeing.
This commit is contained in:
parent
658ef7c730
commit
1fa2a1a74d
|
@ -1173,6 +1173,14 @@ static void pyrna_struct_dealloc(BPy_StructRNA *self)
|
|||
PyObject_GC_UnTrack(self);
|
||||
pyrna_struct_clear(self);
|
||||
}
|
||||
else {
|
||||
PyTypeObject *base = Py_TYPE(self)->tp_base;
|
||||
/* Python temporarily tracks these types when freeing, see Python bug 26617. */
|
||||
if (base && PyType_IS_GC(base)) {
|
||||
PyObject_GC_UnTrack(self);
|
||||
}
|
||||
BLI_assert(!PyObject_GC_IsTracked((PyObject *)self));
|
||||
}
|
||||
#endif /* !USE_PYRNA_STRUCT_REFERENCE */
|
||||
|
||||
/* NOTE: for subclassed PyObjects calling PyObject_DEL() directly crashes. */
|
||||
|
|
Loading…
Reference in New Issue