提交 358664cc 编写于 作者: S Stefan Hajnoczi 提交者: Blue Swirl

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: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: NGerd Hoffmann <kraxel@redhat.com>
Acked-by: NStefan Weil <weil@mail.berlios.de>
Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
上级 7fd3f494
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册