aboutsummaryrefslogtreecommitdiff
path: root/console.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2010-09-20 14:11:19 +0100
committerBlue Swirl <blauwirbel@gmail.com>2010-10-03 06:43:10 +0000
commit358664cc6d1b5f7c36004be0179b36011b81c49d (patch)
treee4ed0b46de41e0bd7f7bc515a1562df6fd5f5737 /console.c
parent7fd3f494409775b491ca08f9026c45da13852a6d (diff)
downloadqemu-358664cc6d1b5f7c36004be0179b36011b81c49d.zip
qemu-358664cc6d1b5f7c36004be0179b36011b81c49d.tar.gz
qemu-358664cc6d1b5f7c36004be0179b36011b81c49d.tar.bz2
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 <stefanha@linux.vnet.ibm.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'console.c')
-rw-r--r--console.c6
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;