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.
This commit is contained in:
Campbell Barton 2011-11-27 14:13:10 +00:00
parent 7025f13894
commit 985e77b723

@ -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) ||