[Bf-blender-cvs] [147164fa7f2] temp-eevee-next-cryptomatte: Fix T100527: Right click in the attribute name field crashes blender.

Bastien Montagne noreply at git.blender.org
Tue Aug 23 12:59:55 CEST 2022


Commit: 147164fa7f26bef0d65c001ddf65ab8b910c0ec2
Author: Bastien Montagne
Date:   Mon Aug 22 12:10:04 2022 +0200
Branches: temp-eevee-next-cryptomatte
https://developer.blender.org/rB147164fa7f26bef0d65c001ddf65ab8b910c0ec2

Fix T100527: Right click in the attribute name field crashes blender.

`UI_context_active_but_prop_get_templateID` became much more widely used
with recent rBfec254364884, which revealed that it did not do any check
on actual type of data it accesses, resulting easily in undefined
behavior.

Now also check the callback function pointer, this should be safe
enough.

Patch by @Severin (Julian Eisel), many thanks!

===================================================================

M	source/blender/editors/interface/interface_templates.c

===================================================================

diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 77837b96e86..4eee9927264 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -571,8 +571,11 @@ static uiBlock *id_search_menu(bContext *C, ARegion *region, void *arg_litem)
 /** \name ID Template
  * \{ */
 
-/* This is for browsing and editing the ID-blocks used */
+static void template_id_cb(bContext *C, void *arg_litem, void *arg_event);
 
+/**
+ * This is for browsing and editing the ID-blocks used.
+ */
 void UI_context_active_but_prop_get_templateID(bContext *C,
                                                PointerRNA *r_ptr,
                                                PropertyRNA **r_prop)
@@ -582,7 +585,7 @@ void UI_context_active_but_prop_get_templateID(bContext *C,
   memset(r_ptr, 0, sizeof(*r_ptr));
   *r_prop = NULL;
 
-  if (but && but->func_argN) {
+  if (but && (but->funcN == template_id_cb) && but->func_argN) {
     TemplateID *template_ui = but->func_argN;
     *r_ptr = template_ui->ptr;
     *r_prop = template_ui->prop;



More information about the Bf-blender-cvs mailing list