On 2014/8/14 18:36, Michael S. Tsirkin wrote:
On Thu, Aug 14, 2014 at 03:29:21PM +0800, zhanghailiang wrote:
From: Li Liu<john.li...@huawei.com>

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

Signed-off-by: zhanghailiang<zhang.zhanghaili...@huawei.com>
Signed-off-by: Li Liu<john.li...@huawei.com>
---
  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);

I would say assert on failure here.
If one is trying to debug, seeing no output will just confuse
matters more.


OK, i will change it to use assert here, thanks.


Reply via email to