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
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2020-01-15 20:08:34 +0300
committerJulian Eisel <eiseljulian@gmail.com>2020-01-15 20:08:34 +0300
commiteca8bae6718d2cba788713bfb677f92f2fa3ca4e (patch)
treed6e2cea6930e77b6872afb7e1ee5e4048f16f7ee /source/creator
parentca49643f3c254a0bdb75f9972880c62bf7f44c3e (diff)
Fix T51054: NULL-dereferences in crash-handler callback
Diffstat (limited to 'source/creator')
-rw-r--r--source/creator/creator_signals.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c
index e8c6e9251bc..446f8f51875 100644
--- a/source/creator/creator_signals.c
+++ b/source/creator/creator_signals.c
@@ -102,15 +102,18 @@ static void sig_handle_crash_backtrace(FILE *fp)
static void sig_handle_crash(int signum)
{
- wmWindowManager *wm = G_MAIN->wm.first;
+ /* Might be called after WM/Main exit, so needs to be careful about NULL-checking before
+ * dereferencing. */
+
+ wmWindowManager *wm = G_MAIN ? G_MAIN->wm.first : NULL;
# ifdef USE_WRITE_CRASH_BLEND
- if (wm->undo_stack) {
+ if (wm && wm->undo_stack) {
struct MemFile *memfile = BKE_undosys_stack_memfile_get_active(wm->undo_stack);
if (memfile) {
char fname[FILE_MAX];
- if (!G_MAIN->name[0]) {
+ if (!(G_MAIN && G_MAIN->name[0])) {
BLI_make_file_string("/", fname, BKE_tempdir_base(), "crash.blend");
}
else {
@@ -131,7 +134,7 @@ static void sig_handle_crash(int signum)
char fname[FILE_MAX];
- if (!G_MAIN->name[0]) {
+ if (!(G_MAIN && G_MAIN->name[0])) {
BLI_join_dirfile(fname, sizeof(fname), BKE_tempdir_base(), "blender.crash.txt");
}
else {