All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ui/gtk: fix NULL pointer dereference
@ 2021-03-07 19:38 Christian Schoenebeck
  2021-03-08  3:45 ` Akihiko Odaki
  0 siblings, 1 reply; 13+ messages in thread
From: Christian Schoenebeck @ 2021-03-07 19:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Akihiko Odaki

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_oss@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



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-03-09  4:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-07 19:38 [PATCH] ui/gtk: fix NULL pointer dereference Christian Schoenebeck
2021-03-08  3:45 ` Akihiko Odaki
2021-03-08 10:39   ` Christian Schoenebeck
2021-03-08 11:31     ` Akihiko Odaki
2021-03-08 12:42       ` Christian Schoenebeck
2021-03-08 13:21         ` Akihiko Odaki
2021-03-08 13:37         ` Peter Maydell
2021-03-08 13:57           ` Akihiko Odaki
2021-03-08 14:03           ` Christian Schoenebeck
2021-03-08 14:17             ` Akihiko Odaki
2021-03-08 14:30               ` Philippe Mathieu-Daudé
2021-03-08 14:57                 ` Christian Schoenebeck
2021-03-09  4:20                   ` Akihiko Odaki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.