From bae1b64525237617ef5c3ab30acfd042e8eca9eb Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 19 Jul 2021 15:59:26 +0200 Subject: Fix broken 'undocumented' case in registration of Macro opertators. Code dealing with macro operators missing description field was slightly different than the one from Operator registration. This lead to invalid memory accesses in some python introspection cases like the i18n messages extraction code in `bl_i18n_utils` module. --- source/blender/windowmanager/intern/wm_operator_type.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index e17d5a9ae70..39435721d1a 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -498,12 +498,11 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, ot->cancel = wm_macro_cancel; ot->poll = NULL; - if (!ot->description) { - /* XXX All ops should have a description but for now allow them not to. */ - ot->description = UNDOCUMENTED_OPERATOR_TIP; - } + /* XXX All ops should have a description but for now allow them not to. */ + BLI_assert((ot->description == NULL) || (ot->description[0])); - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); + RNA_def_struct_ui_text( + ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP); RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); /* Use i18n context from rna_ext.srna if possible (py operators). */ i18n_context = ot->rna_ext.srna ? RNA_struct_translation_context(ot->rna_ext.srna) : @@ -530,16 +529,16 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *), ot->cancel = wm_macro_cancel; ot->poll = NULL; - if (!ot->description) { - ot->description = UNDOCUMENTED_OPERATOR_TIP; - } + /* XXX All ops should have a description but for now allow them not to. */ + BLI_assert((ot->description == NULL) || (ot->description[0])); /* Set the default i18n context now, so that opfunc can redefine it if needed! */ RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; opfunc(ot, userdata); - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); + RNA_def_struct_ui_text( + ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP); RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); -- cgit v1.2.3