diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-03 22:33:44 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-03 22:33:44 +0300 |
commit | 953a031f15e077674e92585cbb085021678860c3 (patch) | |
tree | bf03ea5b896efddee77e21d0b0b3ba2fbe5200da /source/blender/editors/interface/interface_templates.c | |
parent | 88b6dd1392dfa5f2fc3047bc0ec597b2478f6174 (diff) |
UI: Fix use after free for instanced panel expansion
The "set_expand_from_list_data" function has to be called after updating
the panels' custom data pointers. Otherwise the wrong information is
retrieved in the best base and it will cause a crash in the worst case.
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index c27279ab744..f917b65be75 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1890,13 +1890,6 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C) } } else { - /* The expansion might have been changed elsewhere, so we still need to set it. */ - LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { - if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) { - UI_panel_set_expand_from_list_data(C, panel); - } - } - /* Assuming there's only one group of instanced panels, update the custom data pointers. */ Panel *panel = region->panels.first; LISTBASE_FOREACH (ModifierData *, md, modifiers) { @@ -1917,6 +1910,13 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C) panel = panel->next; } + + /* The expansion might have been changed elsewhere, so we still need to set it. */ + LISTBASE_FOREACH (Panel *, panel_iter, ®ion->panels) { + if ((panel_iter->type != NULL) && (panel_iter->type->flag & PNL_INSTANCED)) { + UI_panel_set_expand_from_list_data(C, panel_iter); + } + } } } @@ -2068,13 +2068,6 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_ } } else { - /* The expansion might have been changed elsewhere, so we still need to set it. */ - LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { - if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) { - UI_panel_set_expand_from_list_data(C, panel); - } - } - /* Assuming there's only one group of instanced panels, update the custom data pointers. */ Panel *panel = region->panels.first; LISTBASE_FOREACH (bConstraint *, con, constraints) { @@ -2090,6 +2083,13 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_ panel = panel->next; } + + /* The expansion might have been changed elsewhere, so we still need to set it. */ + LISTBASE_FOREACH (Panel *, panel_iter, ®ion->panels) { + if ((panel_iter->type != NULL) && (panel_iter->type->flag & PNL_INSTANCED)) { + UI_panel_set_expand_from_list_data(C, panel_iter); + } + } } } @@ -2144,13 +2144,6 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C) } } else { - /* The expansion might have been changed elsewhere, so we still need to set it. */ - LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { - if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) { - UI_panel_set_expand_from_list_data(C, panel); - } - } - /* Assuming there's only one group of instanced panels, update the custom data pointers. */ Panel *panel = region->panels.first; LISTBASE_FOREACH (ModifierData *, md, modifiers) { @@ -2171,6 +2164,13 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C) panel = panel->next; } + + /* The expansion might have been changed elsewhere, so we still need to set it. */ + LISTBASE_FOREACH (Panel *, panel_iter, ®ion->panels) { + if ((panel_iter->type != NULL) && (panel_iter->type->flag & PNL_INSTANCED)) { + UI_panel_set_expand_from_list_data(C, panel_iter); + } + } } } @@ -2226,13 +2226,6 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) } } else { - /* The expansion might have been changed elsewhere, so we still need to set it. */ - LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { - if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) { - UI_panel_set_expand_from_list_data(C, panel); - } - } - /* Assuming there's only one group of instanced panels, update the custom data pointers. */ Panel *panel = region->panels.first; LISTBASE_FOREACH (ShaderFxData *, fx, shaderfx) { @@ -2253,6 +2246,13 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) panel = panel->next; } + + /* The expansion might have been changed elsewhere, so we still need to set it. */ + LISTBASE_FOREACH (Panel *, panel_iter, ®ion->panels) { + if ((panel_iter->type != NULL) && (panel_iter->type->flag & PNL_INSTANCED)) { + UI_panel_set_expand_from_list_data(C, panel_iter); + } + } } } |