Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-10-02 12:38:08 +0300
committerBastien Montagne <bastien@blender.org>2020-10-02 12:47:34 +0300
commit062dfab159d3c8e27635c0cd91b15d6736eb61b7 (patch)
tree7099e656ffc16c2740ea995639fd9dc803b8fd3d /source
parent6219d0d145d3f2e6bd30be1c91e952e18db44e74 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/intern/readfile.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index aa2f103c693..6072704100c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -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);