qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v6 10/10] block/vvfat: fix setbuf stream parameter m


From: zhanghailiang
Subject: [Qemu-devel] [PATCH v6 10/10] block/vvfat: fix setbuf stream parameter may be NULL
Date: Thu, 14 Aug 2014 15:29:21 +0800

From: Li Liu <address@hidden>

fopen() may return NULL which will cause setbuf() segmentfault

Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Li Liu <address@hidden>
---
 block/vvfat.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/block/vvfat.c b/block/vvfat.c
index 70176b1..6889ea9 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -1084,7 +1084,10 @@ static int vvfat_open(BlockDriverState *bs, QDict 
*options, int flags,
 
 DLOG(if (stderr == NULL) {
     stderr = fopen("vvfat.log", "a");
-    setbuf(stderr, NULL);
+
+    if (stderr) {
+        setbuf(stderr, NULL);
+    }
 })
 
     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
-- 
1.7.12.4





reply via email to

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