From 82b15553a123e70cb48973489f27aafc77ae6da6 Mon Sep 17 00:00:00 2001 From: Nicolas Hake Date: Thu, 31 Oct 2013 23:21:07 +0100 Subject: [PATCH] C4AppGTK: Avoid SEGV on quit during initialization When C4AbstractApp is destroyed, it will try to reset the current video mode. This includes switching off the fullscreen flag of the render window. When no render window has been created yet, for example during the application initialization phase, this led to a null pointer dereference due to a missing check. --- src/platform/C4AppGTK.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/platform/C4AppGTK.cpp b/src/platform/C4AppGTK.cpp index 2e096a070..6bf4ba05d 100644 --- a/src/platform/C4AppGTK.cpp +++ b/src/platform/C4AppGTK.cpp @@ -189,7 +189,10 @@ void C4AbstractApp::RestoreVideoMode() XRRFreeScreenConfigInfo(conf); fDspModeSet = false; } - gtk_window_unfullscreen(GTK_WINDOW(pWindow->window)); + // pWindow may be unset when C4AbstractApp gets destroyed during the + // initialization code, before a window has been created + if (pWindow) + gtk_window_unfullscreen(GTK_WINDOW(pWindow->window)); } bool C4AbstractApp::GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32_t *piYRes, int32_t *piBitDepth, int32_t *piRefreshRate, uint32_t iMonitor)