From 658ef7c73036dcd2e0c8bae4f6cdcfefcebb17b9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Mar 2024 16:29:46 +1100 Subject: [PATCH] Fix missing call to PyObject_GC_UnTrack WITH_PYTHON_SECURITY Untrack all newly created objects, although this code-path only runs when creating the type fails - which is an exceptional case. --- source/blender/python/intern/bpy_rna.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/python/intern/bpy_rna.cc b/source/blender/python/intern/bpy_rna.cc index 33d54fd3246..97ca03f48f4 100644 --- a/source/blender/python/intern/bpy_rna.cc +++ b/source/blender/python/intern/bpy_rna.cc @@ -7654,6 +7654,12 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr) pyrna = (BPy_StructRNA *)PyObject_New(BPy_StructRNA, &pyrna_struct_Type); #endif +#ifdef USE_PYRNA_STRUCT_REFERENCE + /* #PyType_GenericAlloc will have set tracking. + * We only want tracking when `StructRNA.reference` has been set. */ + PyObject_GC_UnTrack(pyrna); +#endif + #ifdef USE_WEAKREFS if (pyrna != nullptr) { pyrna->in_weakreflist = nullptr;