From 32dd7287681b84f56203c3d736e42433bc94d538 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 22 Jul 2025 19:35:44 +0200 Subject: [PATCH] Fix #141313: Clear Screen active_region for Area swap If screen areas are swapped between windows this can cause an ASAN heap-use-after-free because of invalid screen->active_region pointer. That pointer is quickly reassigned as mouse movement indicates the active region, so just clear them for this operation. Pull Request: https://projects.blender.org/blender/blender/pulls/142877 --- source/blender/editors/screen/area.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 70fc231ab85..150ce266063 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -2614,6 +2614,16 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) BKE_screen_area_free(tmp); MEM_delete(tmp); + /* The areas being swapped could be between different windows, + * so clear screen active region pointers. This is set later + * through regular operations. #141313. */ + wmWindowManager *wm = CTX_wm_manager(C); + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { + if (bScreen *screen = WM_window_get_active_screen(win)) { + screen->active_region = nullptr; + } + } + /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(win);