From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKztv-00069O-DH for qemu-devel@nongnu.org; Tue, 04 Mar 2014 19:41:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKztp-00011Q-AR for qemu-devel@nongnu.org; Tue, 04 Mar 2014 19:41:35 -0500 Received: from mail-oa0-x230.google.com ([2607:f8b0:4003:c02::230]:47617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKztp-00011M-52 for qemu-devel@nongnu.org; Tue, 04 Mar 2014 19:41:29 -0500 Received: by mail-oa0-f48.google.com with SMTP id m1so332278oag.35 for ; Tue, 04 Mar 2014 16:41:28 -0800 (PST) Sender: Corey Minyard From: minyard@acm.org Date: Tue, 4 Mar 2014 18:38:57 -0600 Message-Id: <1393979937-9082-8-git-send-email-minyard@acm.org> In-Reply-To: <1393979937-9082-1-git-send-email-minyard@acm.org> References: <1393979937-9082-1-git-send-email-minyard@acm.org> Subject: [Qemu-devel] [PATCH 7/7] console: Don't use the console if NULL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: bcketchum@gmail.com, Corey Minyard , hwd@huawei.com, afaerber@suse.de, mst@redhat.com From: Corey Minyard Two spots used an allocated console, even though new_console could return NULL. Check the return value first. Signed-off-by: Corey Minyard --- 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