From 037b771e1af53b0f87b73a9fe01e8e660267ec81 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 Nov 2022 19:57:02 +1100 Subject: Fix crash building Python API docs Color space conversion item-function missed checking the context was NULL to return a static array. This caused freed memory access when building docs. --- source/blender/makesrna/intern/rna_nodetree.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'source/blender/makesrna/intern/rna_nodetree.c') diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 7457267a83c..4460a8c8830 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4500,8 +4500,11 @@ static void rna_NodeConvertColorSpace_to_color_space_set(struct PointerRNA *ptr, } static const EnumPropertyItem *rna_NodeConvertColorSpace_color_space_itemf( - bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { + if (C == NULL) { + return rna_enum_color_space_convert_default_items; + } EnumPropertyItem *items = NULL; int totitem = 0; @@ -7323,19 +7326,9 @@ static void def_cmp_convert_color_space(StructRNA *srna) PropertyRNA *prop; RNA_def_struct_sdna_from(srna, "NodeConvertColorSpace", "storage"); - static const EnumPropertyItem color_space_items[] = { - {0, - "NONE", - 0, - "None", - "Do not perform any color transform on load, treat colors as in scene linear space " - "already"}, - {0, NULL, 0, NULL, NULL}, - }; - prop = RNA_def_property(srna, "from_color_space", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); - RNA_def_property_enum_items(prop, color_space_items); + RNA_def_property_enum_items(prop, rna_enum_color_space_convert_default_items); RNA_def_property_enum_funcs(prop, "rna_NodeConvertColorSpace_from_color_space_get", "rna_NodeConvertColorSpace_from_color_space_set", @@ -7345,7 +7338,7 @@ static void def_cmp_convert_color_space(StructRNA *srna) prop = RNA_def_property(srna, "to_color_space", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); - RNA_def_property_enum_items(prop, color_space_items); + RNA_def_property_enum_items(prop, rna_enum_color_space_convert_default_items); RNA_def_property_enum_funcs(prop, "rna_NodeConvertColorSpace_to_color_space_get", "rna_NodeConvertColorSpace_to_color_space_set", -- cgit v1.2.3