qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 7/7] console: Don't use the console if NULL


From: minyard
Subject: [Qemu-devel] [PATCH 7/7] console: Don't use the console if NULL
Date: Tue, 4 Mar 2014 18:38:57 -0600

From: Corey Minyard <address@hidden>

Two spots used an allocated console, even though new_console could
return NULL.  Check the return value first.

Signed-off-by: Corey Minyard <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]