Cleanup: readfile for workspaces: NULLify non-owned data pointers.

`workspace_hook` of wmWindows store pointers for runtime data and to
data belonging to other IDs (workspace's layouts). That kind of pointers
should always be cleaned up on read, it allows for cleaner segfault
crash in case of mistakes in code updating/re-setting them, and avoids
potential security issue of accessing random memory address.

No behavioral change expected here.
This commit is contained in:
Bastien Montagne 2020-10-02 11:38:08 +02:00
parent 6219d0d145
commit 062dfab159
1 changed files with 11 additions and 4 deletions

View File

@ -5483,10 +5483,17 @@ static void direct_link_windowmanager(BlendDataReader *reader, wmWindowManager *
WorkSpaceInstanceHook *hook = win->workspace_hook;
BLO_read_data_address(reader, &win->workspace_hook);
/* We need to restore a pointer to this later when reading workspaces,
* so store in global oldnew-map.
* Note that this is only needed for versionning of older .blend files now.. */
oldnewmap_insert(reader->fd->globmap, hook, win->workspace_hook, 0);
/* This will be NULL for any pre-2.80 blend file. */
if (win->workspace_hook != NULL) {
/* We need to restore a pointer to this later when reading workspaces,
* so store in global oldnew-map.
* Note that this is only needed for versionning of older .blend files now.. */
oldnewmap_insert(reader->fd->globmap, hook, win->workspace_hook, 0);
/* Cleanup pointers to data outside of this data-block scope. */
win->workspace_hook->act_layout = NULL;
win->workspace_hook->temp_workspace_store = NULL;
win->workspace_hook->temp_layout_store = NULL;
}
direct_link_area_map(reader, &win->global_areas);