From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: dongwon.kim@intel.com, qemu-devel@nongnu.org
Subject: Re: [PATCH] ui/gtk: Negative Page number is not valid
Date: Wed, 26 Jun 2024 19:06:11 +0200 [thread overview]
Message-ID: <0399c37b-e4cc-441d-874b-ba3feb537dc4@linaro.org> (raw)
In-Reply-To: <20240626000835.248538-1-dongwon.kim@intel.com>
Hi Dongwon,
On 26/6/24 02:08, dongwon.kim@intel.com wrote:
> From: Dongwon Kim <dongwon.kim@intel.com>
>
> 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 <kraxel@redhat.com>
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
> Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
> ---
> 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(GtkDisplayState *s, gint page)
The caller should check gtk_notebook_get_current_page() != -1.
We might assert(page >= 0) here.
> for (i = 0; i < s->nb_vcs; i++) {
> vc = &s->vc[i];
> p = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), vc->tab_item);
> - if (p == page) {
> + if (p > -1 && p == page) {
Then this is not necessary.
> return vc;
> }
> }
return NULL;
I wonder about returning NULL, maybe just
g_assert_not_reached();
> @@ -357,7 +357,7 @@ static void gtk_release_modifiers(GtkDisplayState *s)
> {
> VirtualConsole *vc = gd_vc_find_current(s);
>
> - if (vc->type != GD_VC_GFX ||
> + if (!vc || vc->type != GD_VC_GFX ||
Then this is not necessary.
> !qemu_console_is_graphic(vc->gfx.dcl.con)) {
> return;
> }
next prev parent reply other threads:[~2024-06-26 17:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 0:08 [PATCH] ui/gtk: Negative Page number is not valid dongwon.kim
2024-06-26 17:06 ` Philippe Mathieu-Daudé [this message]
2024-06-26 18:26 ` Kim, Dongwon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0399c37b-e4cc-441d-874b-ba3feb537dc4@linaro.org \
--to=philmd@linaro.org \
--cc=dongwon.kim@intel.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).