Fix T57655: Crash opening 2.79 file saved with maximized area
authorJulian Eisel <eiseljulian@gmail.com>
Sat, 9 Mar 2019 11:56:56 +0000 (12:56 +0100)
committerJulian Eisel <eiseljulian@gmail.com>
Sat, 9 Mar 2019 12:11:00 +0000 (13:11 +0100)
During screen to workspace/workspace-layout conversion, the first layout
of each workspace would be activated. For temporary full-screens, this
used to be the full-screen layout (IIRC), apparently it's now the
the layout to return to on "Back to Previous". So the 'previous' layout
would be activated, not the full-screen one.
When actually pressing "Back to Previous" now, the operator would first
free the active layout (which it assumes to be the temp full-screen -
wrongly in this case) and then try to activate the non-full-screen one,
causing use-after-free.

source/blender/blenloader/intern/versioning_280.c
source/blender/editors/screen/screen_edit.c

index 8a3e948..3832b67 100644 (file)
@@ -197,12 +197,13 @@ static void do_version_workspaces_after_lib_link(Main *bmain)
 
                        WorkSpace *workspace = BLI_findstring(&bmain->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
                        BLI_assert(workspace != NULL);
-                       ListBase *layouts = BKE_workspace_layouts_get(workspace);
+                       WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, win->screen);
+                       BLI_assert(layout != NULL);
 
                        win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
 
                        BKE_workspace_active_set(win->workspace_hook, workspace);
-                       BKE_workspace_active_layout_set(win->workspace_hook, layouts->first);
+                       BKE_workspace_active_layout_set(win->workspace_hook, layout);
 
                        /* Move scene and view layer to window. */
                        Scene *scene = screen->scene;
index 7556a44..502e5a9 100644 (file)
@@ -1154,6 +1154,9 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
                sc = sa->full;       /* the old screen to restore */
                oldscreen = WM_window_get_active_screen(win); /* the one disappearing */
 
+               BLI_assert(BKE_workspace_layout_screen_get(layout_old) != sc);
+               BLI_assert(BKE_workspace_layout_screen_get(layout_old)->state != SCREENNORMAL);
+
                sc->state = SCREENNORMAL;
                sc->flag = oldscreen->flag;