From 3c09beb3b1f785c920eed3d61f7c2a2a06deba50 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 14 May 2021 19:18:50 +1000 Subject: Fix memory leak in IDPropertyGroup.pop() When popping ID-property groups/arrays, ID-property was removed but not freed. Now the value is converted to a native Python type and freed. --- source/blender/python/intern/bpy_rna.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/python/intern') diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 354aa9b6986..1711637458a 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -5006,8 +5006,13 @@ static PyObject *pyrna_struct_pop(BPy_StructRNA *self, PyObject *args) idprop = IDP_GetPropertyFromGroup(group, key); if (idprop) { - PyObject *ret = BPy_IDGroup_WrapData(self->ptr.owner_id, idprop, group); - IDP_RemoveFromGroup(group, idprop); + /* Don't use #BPy_IDGroup_WrapData as the id-property is being removed from the ID. */ + PyObject *ret = BPy_IDGroup_MapDataToPy(idprop); + /* Internal error. */ + if (UNLIKELY(ret == NULL)) { + return NULL; + } + IDP_FreeFromGroup(group, idprop); return ret; } } -- cgit v1.2.3