Fix crash in RNA when accessing empty property_tags list
authorJulian Eisel <eiseljulian@gmail.com>
Tue, 19 Dec 2017 19:53:19 +0000 (20:53 +0100)
committerJulian Eisel <eiseljulian@gmail.com>
Tue, 19 Dec 2017 19:56:14 +0000 (20:56 +0100)
E.g. running `bpy.context.active_object.cycles.bl_rna.property` in the
console would crash.

Thanks @lijenstina for reporting!

source/blender/makesrna/intern/rna_rna.c

index 507262675b323535e70ea4b091a16dad6cb5bda4..6cd748c0026cd0f98fb6b475a80f078a41d29d4a 100644 (file)
@@ -335,7 +335,7 @@ static void rna_Struct_property_tags_begin(CollectionPropertyIterator *iter, Poi
        /* here ptr->data should always be the same as iter->parent.type */
        StructRNA *srna = (StructRNA *)ptr->data;
        const EnumPropertyItem *tag_defines = RNA_struct_property_tag_defines(srna);
-       unsigned int tag_count = RNA_enum_items_count(tag_defines);
+       unsigned int tag_count = tag_defines ? RNA_enum_items_count(tag_defines) : 0;
 
        rna_iterator_array_begin(iter, (void *)tag_defines, sizeof(EnumPropertyItem), tag_count, 0, NULL);
 }