diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-02-17 15:15:42 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-02-17 15:19:39 +0400 |
commit | 280f9d3b398a073d7a2d64c89d5b6b69939f2f30 (patch) | |
tree | b490945bd4fb83abc9029f0fbac39aac09c49195 | |
parent | d39ffd72174c28a66c3a8d97054d67cc372f088b (diff) |
Fix T38650: Crash from enum item functions returning NULL instead of a
single terminator item.
Ideally no enum item function should return NULL, but since this is very
common and an intuitive mistake, better handle that case gracefully in
the RNA access function.
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index a3dee924c0b..2d8f8eb5c45 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1222,18 +1222,19 @@ void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, En *r_free = false; if (eprop->itemf && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) { - int tot = 0; - if (prop->flag & PROP_ENUM_NO_CONTEXT) *item = eprop->itemf(NULL, ptr, prop, r_free); else *item = eprop->itemf(C, ptr, prop, r_free); - if (r_totitem) { - if (*item) { - for (; (*item)[tot].identifier; tot++) ; - } + if ((*item) == NULL) { + int tot = 0; + RNA_enum_item_end(item, &tot); + } + if (r_totitem) { + int tot = 0; + for (; (*item)[tot].identifier; tot++) ; *r_totitem = tot; } |