DisplaySurface pointer passed to gd_switch() can be NULL, so check this before trying to dereference it.
Fixes: c821a58ee7 ("ui/console: Pass placeholder surface to display") Reported-by: Coverity (CID 1448421) Signed-off-by: Christian Schoenebeck <qemu_...@crudebyte.com> --- ui/gtk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 3edaf041de..a27b27d004 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -567,7 +567,7 @@ static void gd_switch(DisplayChangeListener *dcl, } vc->gfx.ds = surface; - if (surface->format == PIXMAN_x8r8g8b8) { + if (surface && surface->format == PIXMAN_x8r8g8b8) { /* * PIXMAN_x8r8g8b8 == CAIRO_FORMAT_RGB24 * @@ -580,7 +580,7 @@ static void gd_switch(DisplayChangeListener *dcl, surface_width(surface), surface_height(surface), surface_stride(surface)); - } else { + } else if (surface) { /* Must convert surface, use pixman to do it. */ vc->gfx.convert = pixman_image_create_bits(PIXMAN_x8r8g8b8, surface_width(surface), -- 2.20.1