]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
gtk: Skip drawing if console surface is NULL
authorWeifeng Liu <weifeng.liu.z@gmail.com>
Mon, 14 Jul 2025 14:17:54 +0000 (22:17 +0800)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 30 Sep 2025 07:06:36 +0000 (11:06 +0400)
In gtk draw/render callbacks, add an early NULL check for the console
surface and skip drawing if it's NULL. Otherwise, attempting to fetch
its width and height crash. This change fixes Coverity CID 1610328.

In practice, this case wouldn't happen at all because we always install
a placeholder surface to the console when there is nothing to display.

Resolves: Coverity CID 1610328
Signed-off-by: Weifeng Liu <weifeng.liu.z@gmail.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20250714141758.10062-1-weifeng.liu.z@gmail.com>

ui/gtk-egl.c
ui/gtk-gl-area.c

index 0b787bea25eee20cebba939be93512766412fc97..ae9239999cdb6a9e7b75187ed4f69ac90dabe1ea 100644 (file)
@@ -72,7 +72,7 @@ void gd_egl_draw(VirtualConsole *vc)
 #endif
     int ww, wh, pw, ph, gs;
 
-    if (!vc->gfx.gls) {
+    if (!vc->gfx.gls || !vc->gfx.ds) {
         return;
     }
 
@@ -112,9 +112,6 @@ void gd_egl_draw(VirtualConsole *vc)
         }
 #endif
     } else {
-        if (!vc->gfx.ds) {
-            return;
-        }
         eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
                        vc->gfx.esurface, vc->gfx.ectx);
 
index 8151cc413cf7f287be8b0dcfa5b7528a10267af4..05fc38096eca3221858db8d22eb54bfa25770898 100644 (file)
@@ -48,7 +48,7 @@ void gd_gl_area_draw(VirtualConsole *vc)
     int fbw, fbh;
     int wx_offset, wy_offset;
 
-    if (!vc->gfx.gls) {
+    if (!vc->gfx.gls || !vc->gfx.ds) {
         return;
     }
 
@@ -135,9 +135,6 @@ void gd_gl_area_draw(VirtualConsole *vc)
         }
 #endif
     } else {
-        if (!vc->gfx.ds) {
-            return;
-        }
         gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
 
         surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, pw, ph);