From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39205 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oxg9a-0006pw-PL for qemu-devel@nongnu.org; Mon, 20 Sep 2010 09:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oxg9Y-0004yN-Kn for qemu-devel@nongnu.org; Mon, 20 Sep 2010 09:11:30 -0400 Received: from mtagate2.de.ibm.com ([195.212.17.162]:60754) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oxg9Y-0004xt-9V for qemu-devel@nongnu.org; Mon, 20 Sep 2010 09:11:28 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id o8KDBRs5012646 for ; Mon, 20 Sep 2010 13:11:27 GMT Received: from d12av01.megacenter.de.ibm.com (d12av01.megacenter.de.ibm.com [9.149.165.212]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o8KDBQLQ3674362 for ; Mon, 20 Sep 2010 15:11:26 +0200 Received: from d12av01.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av01.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o8KDBQho001383 for ; Mon, 20 Sep 2010 15:11:26 +0200 From: Stefan Hajnoczi Date: Mon, 20 Sep 2010 14:11:19 +0100 Message-Id: <1284988279-8900-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Gerd Hoffmann , Michal Suchanek , Stefan Hajnoczi The console_select() function does not check that active_console is non-NULL before dereferencing it. When invoked with qemu -nodefaults it is possible to hit this case. This patch checks that active_console is non-NULL before stashing away the old console dimensions in console_select(). Signed-off-by: Stefan Hajnoczi --- 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