]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
sdl2: fix crash in handle_windowevent() when restoring the screen size
authorAlberto Garcia <berto@igalia.com>
Mon, 8 Jun 2015 09:12:15 +0000 (11:12 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 29 Jul 2015 23:33:50 +0000 (18:33 -0500)
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.

Cc: qemu-stable@nongnu.org
Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 08d49df0dbaacc220a099dbfb644e1dc0eda57be)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
ui/sdl2.c

index 60e3c3b6fa5bec8436cc7f9470f845da6fe2562c..f10c6a4c89d4f478a3f96d31c72b82174693a5c3 100644 (file)
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -511,6 +511,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:
         {