Received: from [140.186.70.92] (port=58902 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P12Lg-0005GS-6x for qemu-devel@nongnu.org; Wed, 29 Sep 2010 15:29:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P12Lf-0008RR-8G for qemu-devel@nongnu.org; Wed, 29 Sep 2010 15:29:52 -0400 Received: from moutng.kundenserver.de ([212.227.17.8]:56866) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P12Le-0008Pt-Qu for qemu-devel@nongnu.org; Wed, 29 Sep 2010 15:29:51 -0400 From: Stefan Weil Date: Wed, 29 Sep 2010 21:29:38 +0200 Message-Id: <1285788578-18540-1-git-send-email-weil@mail.berlios.de> Subject: [Qemu-devel] [PATCH] console: Fix crash with missing active_console (null pointer access) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers Console selection crashed qemu when there was no active console. Run "qemu -nodefaults" with SDL configured and press alt-ctrl-2 to reproduce this bug. Check active_console before trying to get the dimensions of it (this was obviously the last location which did not do this check). Signed-off-by: Stefan Weil --- console.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/console.c b/console.c index 698bc10..c1728b1 100644 --- a/console.c +++ b/console.c @@ -1060,8 +1060,10 @@ void console_select(unsigned int index) if (index >= MAX_CONSOLES) return; - active_console->g_width = ds_get_width(active_console->ds); - active_console->g_height = ds_get_height(active_console->ds); + if (active_console) { + active_console->g_width = ds_get_width(active_console->ds); + active_console->g_height = ds_get_height(active_console->ds); + } s = consoles[index]; if (s) { DisplayState *ds = s->ds; -- 1.7.1