Commit: 280f9d3b398a073d7a2d64c89d5b6b69939f2f30
Author: Lukas Tönne
Date:   Mon Feb 17 12:15:42 2014 +0100
https://developer.blender.org/rB280f9d3b398a073d7a2d64c89d5b6b69939f2f30

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.

===================================================================

M       source/blender/makesrna/intern/rna_access.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_access.c 
b/source/blender/makesrna/intern/rna_access.c
index a3dee92..2d8f8eb 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;
                }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to