diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-08-18 11:29:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-08-18 11:29:27 +0300 |
commit | 4e468ceb71745bb0bf745f7309f6a7d7ac579ba5 (patch) | |
tree | 6484f144a0bbf729ad6138c9fa651ed9b0542494 | |
parent | ac28a4fba7183b2eb6ac6641c80d20587be58a1a (diff) |
PyAPI: Fix memory leak w/ empty, allocated enums
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index eda880d4dce..67f2f1fdee6 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -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... */ |