From nobody Sun Nov 24 23:49:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1719362399; cv=none; d=zohomail.com; s=zohoarc; b=TMJaP9IEUGJDUFmJtSTaGo87tIsAt7tcIosoi+1IwgqCFaA3b41uC8VcVmbM1bo1kT6Rp09I7IbrLUJy5gCruKvZrubEFRZtwYz57FcvBLUAJwz2xmsGriLXg4mHAAzaxDEahqru9XUEq13YaWqrPohVCzMvAETPAdZ/MniDQFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719362399; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=TTM6iRqp++o35V+YJjTbDG/GyYrapI3qYl+PFrUZUyk=; b=UDGmKD9Z0znkYXlWKQ6bY6e1D7G0D3eNG6mzyVNTf0F917vrro7aS7GjeDjbfRukA88RASfC66LlufIeXYIOAnqqMUHnSRLgEzbrWE/cM5gbGSaxl6pwtBqD0TdBUuo5l0I73eTupKK3LU+WXgfPeuj02R1f1yPTiULGkVZOMRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1719362399151970.8291566966308; Tue, 25 Jun 2024 17:39:59 -0700 (PDT) Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMGZZ-0002Qh-1F; Tue, 25 Jun 2024 20:31:47 -0400 Received: from [2001:470:142:3::10] (helo=eggs.gnu.org) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMGZI-0002Pw-Mr for qemu-devel@nongnu.org; Tue, 25 Jun 2024 20:31:24 -0400 Received: from mgamail.intel.com ([198.175.65.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMGYY-00057H-Il for qemu-devel@nongnu.org; Tue, 25 Jun 2024 20:31:16 -0400 Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 17:09:42 -0700 Received: from dongwonk-z390-aorus-ultra.fm.intel.com ([10.105.129.124]) by fmviesa009.fm.intel.com with ESMTP; 25 Jun 2024 17:09:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719361839; x=1750897839; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=tCWf9Ded02uZKg7enBRwrRrvysh18GPrddTIrYhqoUk=; b=Ud5u+DXb/3j0gVdPEy0Dc0pazkBS6iXQDVi7DXthemNd21I8kOXoiQin JK745uvLA/3Rbn9hUAtHlV3zzwFBul1kKc632ie3C54RVL/6A1Lw4kVdG OuzdhOwtTNTnCgZQXXwSvzAgM0XSCrhKDhTZKrECBMmdbpxjwgAg10B4i Vvs5ZBNDdFxU7IQqZZEION7RPo9XEMN4mVrCKAxNEEQxfzh7eubqU+lST Ho3+AwYrJTAQn/GEHvXAc2oi1ULkk+2rCpwRYB2j/YNLXhTkG+uriafSk D/+DkbPw7s8gMTnBxtm6xAB5bfjqq5MGyN3Q1v2Nuu/OJVo/RtoUwPuPw g==; X-CSE-ConnectionGUID: cRy5Wo/VSWuwyDGkjKpbYw== X-CSE-MsgGUID: jbIPoqRiSPaBqQy8R5yD+w== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="38922351" X-IronPort-AV: E=Sophos;i="6.08,265,1712646000"; d="scan'208";a="38922351" X-CSE-ConnectionGUID: h0yq391ARp+QRxqe/gvPcg== X-CSE-MsgGUID: 9lNf7HgbQNi9ufBOmvKLHw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,265,1712646000"; d="scan'208";a="43889055" From: dongwon.kim@intel.com To: qemu-devel@nongnu.org Subject: [PATCH] ui/gtk: Negative Page number is not valid Date: Tue, 25 Jun 2024 17:08:35 -0700 Message-Id: <20240626000835.248538-1-dongwon.kim@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=198.175.65.9; envelope-from=dongwon.kim@intel.com; helo=mgamail.intel.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, T_SPF_HELO_TEMPERROR=0.01, T_SPF_TEMPERROR=0.01 autolearn=no 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 @intel.com) X-ZM-MESSAGEID: 1719362400655100002 From: Dongwon Kim Negative page number means the page with that number does not belong to the notebook so it shouldn't be used as a valid page number in gd_vc_find_by_page. This function should just return null in such case. This change, however, will cause a segfault during detaching /untabifying process in gtk_release_modifiers because the current VC's page number suddenly becomes '-1' as soon as the VC is detached, which makes gd_vc_find_by_page return null. So gtk_release_modifiers should do the null check on VC returned from gd_vc_find_by_page. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 93b13b7a30..1f8523fd81 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -164,7 +164,7 @@ static VirtualConsole *gd_vc_find_by_page(GtkDisplaySta= te *s, gint page) for (i =3D 0; i < s->nb_vcs; i++) { vc =3D &s->vc[i]; p =3D gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), vc->tab_ite= m); - if (p =3D=3D page) { + if (p > -1 && p =3D=3D page) { return vc; } } @@ -357,7 +357,7 @@ static void gtk_release_modifiers(GtkDisplayState *s) { VirtualConsole *vc =3D gd_vc_find_current(s); =20 - if (vc->type !=3D GD_VC_GFX || + if (!vc || vc->type !=3D GD_VC_GFX || !qemu_console_is_graphic(vc->gfx.dcl.con)) { return; } --=20 2.34.1