diff options
author | Julian Eisel <julian@blender.org> | 2020-11-02 23:47:08 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-11-03 02:00:41 +0300 |
commit | a750acab78cf38ca8f010c4ac81ec948faa79dd5 (patch) | |
tree | 6603e8747261895ff1b9dc9768cf47be202fefd3 /source/blender/editors/space_file/filesel.c | |
parent | 9cfcc273194e6e9706fefaac739b3d73eca2f62f (diff) |
Fix possible use-after-free when closing Blender with File Browser open
I think there wasn't actually any issue currently, but only by luck. We still
passed around and NULL-checked a pointer to freed memory (the file operator,
`SpaceFile.op`) which is easy to break and should be avoided.
Noticed while testing D8598.
Diffstat (limited to 'source/blender/editors/space_file/filesel.c')
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 42b2806814b..5d90403937a 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -61,6 +61,7 @@ #include "BLF_api.h" #include "ED_fileselect.h" +#include "ED_screen.h" #include "WM_api.h" #include "WM_types.h" @@ -1050,3 +1051,20 @@ void file_params_renamefile_activate(SpaceFile *sfile, FileSelectParams *params) params->rename_flag = 0; } } + +ScrArea *ED_fileselect_handler_area_find(const wmWindow *win, const wmOperator *file_operator) +{ + bScreen *screen = WM_window_get_active_screen(win); + + ED_screen_areas_iter (win, screen, area) { + if (area->spacetype == SPACE_FILE) { + SpaceFile *sfile = area->spacedata.first; + + if (sfile->op == file_operator) { + return area; + } + } + } + + return NULL; +} |