diff mbox

[PULL,2/5] sdl: Fix crash when calling sdl_switch() with NULL surface

Message ID 1425376688-4065-3-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann March 3, 2015, 9:58 a.m. UTC
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

This happens for example when doing ctrl-alt-u and segfaults

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/ui/sdl.c b/ui/sdl.c
index b89182a..8bdbf52 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -135,12 +135,13 @@  static void do_sdl_resize(int width, int height, int bpp)
 static void sdl_switch(DisplayChangeListener *dcl,
                        DisplaySurface *new_surface)
 {
-    PixelFormat pf = qemu_pixelformat_from_pixman(new_surface->format);
+    PixelFormat pf;
 
     /* temporary hack: allows to call sdl_switch to handle scaling changes */
     if (new_surface) {
         surface = new_surface;
     }
+    pf = qemu_pixelformat_from_pixman(surface->format);
 
     if (!scaling_active) {
         do_sdl_resize(surface_width(surface), surface_height(surface), 0);