Fix #116680: Crash disabling an add-on used in the file-selector
Clear SpaceFile::op pointer when unregistering an operator to prevent a use after free error.
This commit is contained in:
@@ -384,6 +384,22 @@ void WM_operator_stack_clear(wmWindowManager *wm)
|
||||
|
||||
void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot)
|
||||
{
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
switch (area->spacetype) {
|
||||
case SPACE_FILE: {
|
||||
SpaceFile *sfile = static_cast<SpaceFile *>(area->spacedata.first);
|
||||
if (sfile->op && sfile->op->type == ot) {
|
||||
/* Freed as part of the handler. */
|
||||
sfile->op = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
ListBase *lb[2] = {&win->handlers, &win->modalhandlers};
|
||||
for (int i = 0; i < ARRAY_SIZE(lb); i++) {
|
||||
|
||||
Reference in New Issue
Block a user