From: Corey Minyard <cminy...@mvista.com> Two spots used an allocated console, even though new_console could return NULL. Check the return value first.
Signed-off-by: Corey Minyard <cminy...@mvista.com> --- ui/console.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/console.c b/ui/console.c index a204ce2..8d4ca81 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1582,6 +1582,9 @@ QemuConsole *graphic_console_init(DeviceState *dev, ds = get_alloc_displaystate(); trace_console_gfx_new(); s = new_console(ds, GRAPHIC_CONSOLE); + if (!s) { + return NULL; + } s->hw_ops = hw_ops; s->hw = opaque; if (dev) { @@ -1747,7 +1750,9 @@ static void text_console_init(CharDriverState *chr, ChardevVC *vc, Error **errp) s = new_console(NULL, TEXT_CONSOLE); } else { s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE); - s->surface = qemu_create_displaysurface(width, height); + if (s) { + s->surface = qemu_create_displaysurface(width, height); + } } if (!s) { -- 1.8.3.1