Merge branch 'master' into blender2.8
[blender.git] / source / blender / python / intern / bpy_rna.c
index e08f1bca10c024b686f538c4d8bcca1933177b15..91ddec5390909386aecece49658717c6090c8398 100644 (file)
@@ -1395,7 +1395,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
                }
                else {
                        EnumPropertyItem *enum_item;
-                       bool free = false;
+                       bool free;
 
                        /* don't throw error here, can't trust blender 100% to give the
                         * right values, python code should not generate error for that */
@@ -1404,6 +1404,9 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
                                ret = PyUnicode_FromString(enum_item->identifier);
                        }
                        else {
+                               if (free) {
+                                       MEM_freeN(enum_item);
+                               }
                                RNA_property_enum_items(NULL, ptr, prop, &enum_item, NULL, &free);
 
                                /* Do not print warning in case of DummyRNA_NULL_items, this one will never match any value... */