[Bf-blender-cvs] [8f8ae06b515] master: Fix use-after-free error when exiting on WIN32

Campbell Barton noreply at git.blender.org
Fri Sep 9 14:48:38 CEST 2022


Commit: 8f8ae06b515c0fe479ba8b3cfb27c354c031e483
Author: Campbell Barton
Date:   Fri Sep 9 22:38:55 2022 +1000
Branches: master
https://developer.blender.org/rB8f8ae06b515c0fe479ba8b3cfb27c354c031e483

Fix use-after-free error when exiting on WIN32

The logging API was freed before calling wm_autosave_delete that called
BKE_appdir_folder_id_create to get the auto-save location (when the
temporary directory wasn't found). Detecting BLENDER_USER_AUTOSAVE would
log details about the path, which would read data freed by CLG_exit.
Resolve by calling CLG_exit last.

===================================================================

M	source/blender/windowmanager/intern/wm_init_exit.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 8163b39b3dd..283b87f1a2f 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -634,13 +634,15 @@ void WM_exit_ex(bContext *C, const bool do_python)
   BKE_sound_exit();
 
   BKE_appdir_exit();
-  CLG_exit();
 
   BKE_blender_atexit();
 
   wm_autosave_delete();
 
   BKE_tempdir_session_purge();
+
+  /* Keep last (or near last) so logging can be used right up until everything is shut-down. */
+  CLG_exit();
 }
 
 void WM_exit(bContext *C)



More information about the Bf-blender-cvs mailing list