From nobody Sat Nov 15 10:52:04 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752507746; cv=none; d=zohomail.com; s=zohoarc; b=QTkL4QkLf5tEIdsgiNCbo7fKFbghbDZuGWlM4tzAdkBzciDtRTeWYTG6/Hc05ywWC9GS/3/A6YjBysn5y19kWOQk8tcmkHjj995QTNgWgaBZBw7Su3m2Cax46cY2E4I2AaIwskIkJA9M2X3eGoG/NASQACq8aaCba8mI4d2UxjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752507746; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BnEv1rhPyuqGeOqhJG81aiCKY6SFUNUyQxrFxmuLHBA=; b=EuIn7T4yG25yVLoHM7bElWlC8mKEu46zowF0wWfxUNsd8rT7/JAY/6/nZ3JHuGw/xNONmEHhVHaHYUydPuPtyiKo2UjuljbqMUypZzcXtmwJulxN9psibBC3U9mt6KAeKfzD981qtodSVj6Rc/WfuRNhQAdEfMO/6GXiiQxqmBg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752507746897821.7327740062431; Mon, 14 Jul 2025 08:42:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ubLJc-0002mJ-03; Mon, 14 Jul 2025 11:42:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubK0a-0008Hn-Ew for qemu-devel@nongnu.org; Mon, 14 Jul 2025 10:18:21 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ubK0X-0000PK-1c for qemu-devel@nongnu.org; Mon, 14 Jul 2025 10:18:18 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-b3182c6d03bso5023683a12.0 for ; Mon, 14 Jul 2025 07:18:15 -0700 (PDT) Received: from localhost ([103.192.224.247]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31c3e973e75sm10663890a91.16.2025.07.14.07.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 07:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752502694; x=1753107494; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BnEv1rhPyuqGeOqhJG81aiCKY6SFUNUyQxrFxmuLHBA=; b=Zzh0iTJmPsHWoZCPV95c1h5Fkq6N2KZdgNSPxge6muAG/qm5IaCJb8NwwULbluPasI OIpUPuJ00TOGFqyCRNx5DbrMkvwuHBXL5vlnbsNlzlN+GVjtIkao7LZ3PyiO7TqOdXxn SYN+3KWuEgduLJhGqgzC4JXH6Ul82Z1p9RSnMzR3kFo3mcoHvPusyuckC02WXkEHzwPK ceOW5CHVAExSTajZq6ZRk6lAO1Y5PIVv5+U8w4tEzNl8vv74sm7h0jY4YrQ19cDvboLJ fi0v+VrnFEabECwqwHm56k0UPIWzZawo8/sCpTjRKCMYWTLuCnjGlSg6Dj3ZKZuhGxa0 dGrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752502694; x=1753107494; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BnEv1rhPyuqGeOqhJG81aiCKY6SFUNUyQxrFxmuLHBA=; b=erAletC3WmBf7705FZabSq8kN8NH0Ph4qJS1JOTStJYMeKqDmOhogK5IF+sqIJTU4o I2mwE/1E1yHM7BzDXA59v4JWzThB4CxfURI4vV9lHLkcTqty4CX7sOksq2X8C6KLS0Cm +B75jmAvC/dOm7NcB+GFBz8T47vQJtdBIoACE2Jx2fhE3v9RKV2mRHsVKJW27bbmj6fR Na7CJBoX1ztjhPRiYR9tc0bRRksXnOBExbNnVRf+KUnI4q5lHDOJnXa4bTI0BOXVoMRR a6KapAle15WzlVj05hX86zZytiUjT5ATBuXFCfypr0sD7m0OMxiXC6bs5eF15lFZFjPy /jbg== X-Gm-Message-State: AOJu0YyTLcbY+sWq+oqs+RRJqk1g552mMUd2wBvq2Lk3pHFzTn0caf0i 790ZeSZA8pYTrikBrSKQ1uGngaJcpD0e725fBXDcUhwUKzD0eYPriFi/waa8s+WGS5w= X-Gm-Gg: ASbGnctPWCmLiCHKp5aQ6fcjSpKc17amMPoX5ddXL79wVFYAV7d6P0KzWN+qFYf3MFR 1P5QFfKZEJgklgjEFCGJ+OzR9DS3qwMyv2BIO7/Kz0kM3v5rFMG3/xMqtDwwT8osVdafH3LCyIy 8iIaaARzLYNeSBk+3RPQyOEd46Ar8GX1qgAfmbh0DXBt/r7eoILBkYNk+s4IanO8QxSeEIlLLho RVuAhN8M3XT9Fgn87nD/iwS/uwzNqThQk7JEX/3dYQkoNzgJOIT1MrPBncAdlUyecym+d/Tmmfh m3Z6h8vKjkL/48hAXkuXUHG9+2SNiEqbPm3hHv/mdtjQYBxy8yGR5qDkpW8NsL3m1ZFa94ARVjM k5BqcNeD3zKWFB8eE0NM2xmAJz/s= X-Google-Smtp-Source: AGHT+IE/Si003LAV3ECTYELp+xDAVyo3ipn/4u8D1TlcNQiKgtZYwgCeWgKREFnmKQY9apmmVyDKNA== X-Received: by 2002:a17:90b:4c0a:b0:313:17e3:7ae0 with SMTP id 98e67ed59e1d1-31c4cd5618dmr17698480a91.34.1752502693722; Mon, 14 Jul 2025 07:18:13 -0700 (PDT) From: Weifeng Liu To: qemu-devel@nongnu.org Cc: Weifeng Liu , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Dmitry Osipenko , Peter Maydell , Akihiko Odaki , Vivek Kasireddy , Dongwon Kim Subject: [PATCH] gtk: Skip drawing if console surface is NULL Date: Mon, 14 Jul 2025 22:17:54 +0800 Message-ID: <20250714141758.10062-1-weifeng.liu.z@gmail.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=weifeng.liu.z@gmail.com; helo=mail-pg1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752507748628116600 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau --- ui/gtk-egl.c | 5 +---- ui/gtk-gl-area.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 0b787bea25..ae9239999c 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -72,7 +72,7 @@ void gd_egl_draw(VirtualConsole *vc) #endif int ww, wh, pw, ph, gs; =20 - if (!vc->gfx.gls) { + if (!vc->gfx.gls || !vc->gfx.ds) { return; } =20 @@ -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); =20 diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 8151cc413c..05fc38096e 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -48,7 +48,7 @@ void gd_gl_area_draw(VirtualConsole *vc) int fbw, fbh; int wx_offset, wy_offset; =20 - if (!vc->gfx.gls) { + if (!vc->gfx.gls || !vc->gfx.ds) { return; } =20 @@ -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)); =20 surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, pw, ph); --=20 2.49.0