PyAPI: Fix memory leak w/ empty, allocated enums

This commit is contained in:
Campbell Barton 2017-08-18 18:29:27 +10:00
parent ac28a4fba7
commit 4e468ceb71
1 changed files with 4 additions and 1 deletions

View 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... */