From 985e77b723d558fc5aa14b317d18bafbaada3628 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Nov 2011 14:13:10 +0000 Subject: accessing rna 'default_flag' attribute of a non enum-flag could crash. eg. bpy.types.Modifier.bl_rna.properties["type"].default_flag now check the default/default_flag match the enum property they are used with. --- source/blender/makesrna/intern/rna_rna.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/blender/makesrna/intern/rna_rna.c') diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 424a08f15cb..940e2e749e3 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -746,7 +746,7 @@ static int rna_StringProperty_max_length_get(PointerRNA *ptr) return ((StringPropertyRNA*)prop)->maxlength; } -static EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) +static EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop_parent, int *free) { PropertyRNA *prop= (PropertyRNA*)ptr->data; EnumPropertyRNA *eprop; @@ -754,6 +754,11 @@ static EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, PointerRNA rna_idproperty_check(&prop, ptr); eprop= (EnumPropertyRNA*)prop; + /* incompatible default attributes */ + if ((prop_parent->flag & PROP_ENUM_FLAG) != (prop->flag & PROP_ENUM_FLAG)) { + return NULL; + } + if( (eprop->itemf == NULL) || (eprop->itemf == rna_EnumProperty_default_itemf) || (ptr->type == &RNA_EnumProperty) || -- cgit v1.2.3