Fix segfault on screendump with -nographic

Submitted by Alexander Graf on May 26, 2011, 7:56 p.m.

Details

Message ID 1306439782-25277-1-git-send-email-agraf@suse.de
State New
Headers show

Commit Message

Alexander Graf May 26, 2011, 7:56 p.m.
When running -nographic and calling "screendump" on the monitor, qemu
segfaults. Fix the invalid pointer dereference by checking for NULL.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 console.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/console.c b/console.c
index 871c1d4..9c6addf 100644
--- a/console.c
+++ b/console.c
@@ -180,7 +180,7 @@  void vga_hw_screen_dump(const char *filename)
     active_console = consoles[0];
     /* There is currently no way of specifying which screen we want to dump,
        so always dump the first one.  */
-    if (consoles[0]->hw_screen_dump)
+    if (consoles[0] && consoles[0]->hw_screen_dump)
         consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
     active_console = previous_active_console;
 }