From 358664cc6d1b5f7c36004be0179b36011b81c49d Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 20 Sep 2010 14:11:19 +0100 Subject: console: Avoid dereferencing NULL active_console 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 Acked-by: Gerd Hoffmann Acked-by: Stefan Weil Signed-off-by: Blue Swirl --- console.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'console.c') diff --git a/console.c b/console.c index 698bc10a60..c1728b1e04 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; -- cgit v1.2.1