From 09c0c86d83af9ed6dd2628dd9f594fcce0bed55a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Jun 2023 10:29:14 +1000 Subject: [PATCH] Fix property tags dummy enum value holding a reference to stack memory Also update the doc-string to include a warning about this. --- source/blender/makesrna/RNA_define.h | 4 ++++ source/blender/makesrna/intern/rna_rna.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index a7696483748..52943456486 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -384,6 +384,10 @@ void RNA_def_property_array(PropertyRNA *prop, int length); void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[]); void RNA_def_property_range(PropertyRNA *prop, double min, double max); +/** + * \param item: An array of enum properties terminated by null members. + * \warning take care not to reference stack memory as the reference to `item` is held by `prop`. + */ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item); void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type); void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 69e9dc426da..983b2b2a6f2 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -2944,7 +2944,7 @@ static void rna_def_property(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - EnumPropertyItem dummy_prop_tags[] = { + static const EnumPropertyItem dummy_prop_tags[] = { {0, NULL, 0, NULL, NULL}, };