diff mbox

sdl2: fix crash in handle_windowevent() when restoring the screen size

Message ID 1433364518-10436-1-git-send-email-berto@igalia.com
State New
Headers show

Commit Message

Alberto Garcia June 3, 2015, 8:48 p.m. UTC
The Ctrl-Alt-u keyboard shortcut restores the screen to its original
size. In the SDL2 UI this is done by destroying the window and
creating a new one. The old window emits SDL_WINDOWEVENT_HIDDEN when
it's destroyed, but trying to call SDL_GetWindowFromID() from that
event's window ID returns a null pointer. handle_windowevent() assumes
that the pointer is never null so it results in a crash.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl2.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 2d60179..5cb75aa 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -521,6 +521,10 @@  static void handle_windowevent(SDL_Event *ev)
 {
     struct sdl2_console *scon = get_scon_from_window(ev->window.windowID);
 
+    if (!scon) {
+        return;
+    }
+
     switch (ev->window.event) {
     case SDL_WINDOWEVENT_RESIZED:
         {