qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] Avoid segfault in cpu_dump_state


From: Fabien Chouteau
Subject: [Qemu-devel] [PATCH] Avoid segfault in cpu_dump_state
Date: Tue, 15 May 2012 11:39:09 +0200

Do not call cpu_dump_state if logfile is NULL.

Signed-off-by: Fabien Chouteau <address@hidden>
---
 qemu-log.h |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qemu-log.h b/qemu-log.h
index fccfb110..2cd5ffa 100644
--- a/qemu-log.h
+++ b/qemu-log.h
@@ -51,7 +51,12 @@ extern int loglevel;
 /* Special cases: */
 
 /* cpu_dump_state() logging functions: */
-#define log_cpu_state(env, f) cpu_dump_state((env), logfile, fprintf, (f));
+#define log_cpu_state(env, f)                          \
+do {                                                   \
+    if (logfile != NULL) {                             \
+        cpu_dump_state((env), logfile, fprintf, (f));  \
+    }                                                  \
+ } while (0)
 #define log_cpu_state_mask(b, env, f) do {           \
       if (loglevel & (b)) log_cpu_state((env), (f)); \
   } while (0)
-- 
1.7.9.5




reply via email to

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