From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrdUx-000703-98 for qemu-devel@nongnu.org; Thu, 20 Nov 2014 20:59:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrdUr-0000iy-2g for qemu-devel@nongnu.org; Thu, 20 Nov 2014 20:58:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrdUq-0000iq-Ra for qemu-devel@nongnu.org; Thu, 20 Nov 2014 20:58:52 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAL1wout025597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 20 Nov 2014 20:58:51 -0500 From: Fam Zheng Date: Fri, 21 Nov 2014 09:59:09 +0800 Message-Id: <1416535149-18376-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH] gtk: Don't crash if -nodefaults List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann This fixes a crash by just skipping the vte resize hack if cur is NULL. Reproducer: qemu-system-x86_64 -nodefaults Signed-off-by: Fam Zheng --- ui/gtk.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 38bf463..29e09a7 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1910,15 +1910,17 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) #ifdef VTE_RESIZE_HACK { VirtualConsole *cur = gd_vc_find_current(s); - int i; - - for (i = 0; i < s->nb_vcs; i++) { - VirtualConsole *vc = &s->vc[i]; - if (vc && vc->type == GD_VC_VTE && vc != cur) { - gtk_widget_hide(vc->vte.terminal); + if (cur) { + int i; + + for (i = 0; i < s->nb_vcs; i++) { + VirtualConsole *vc = &s->vc[i]; + if (vc && vc->type == GD_VC_VTE && vc != cur) { + gtk_widget_hide(vc->vte.terminal); + } } + gd_update_windowsize(cur); } - gd_update_windowsize(cur); } #endif -- 1.9.3