diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-18 13:26:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-18 13:26:07 +0400 |
commit | 0454c817ef3c11c94359a6ebded99e4181d42ef7 (patch) | |
tree | c68aee5b7ec4566322bcfece870fd8dd09a470a6 /source | |
parent | ebe47add0816831ac0d1ce77a47a09da60d4af59 (diff) |
fix a crash when getting the value of an enum.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index a89d52e9fca..36694e1adc1 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1107,21 +1107,26 @@ int RNA_property_enum_value(bContext *C, PointerRNA *ptr, PropertyRNA *prop, con { EnumPropertyItem *item, *item_array; int free, found; - + RNA_property_enum_items(C, ptr, prop, &item_array, NULL, &free); - - for(item= item_array; item->identifier; item++) { - if(item->identifier[0] && strcmp(item->identifier, identifier)==0) { - *value = item->value; - break; + + if(item_array) { + for(item= item_array; item->identifier; item++) { + if(item->identifier[0] && strcmp(item->identifier, identifier)==0) { + *value = item->value; + break; + } } - } - - found= (item->identifier != NULL); /* could be alloc'd, assign before free */ - if(free) - MEM_freeN(item_array); + found= (item->identifier != NULL); /* could be alloc'd, assign before free */ + if(free) { + MEM_freeN(item_array); + } + } + else { + found= 0; + } return found; } |