Patchwork [RFC,4/5] avoid dandling pointers

login
register
mail settings
Submitter Frediano Ziglio
Date July 20, 2011, 7:57 a.m.
Message ID <1311148624-5640-5-git-send-email-freddy77@gmail.com>
Download mbox | patch
Permalink /patch/105599/
State New
Headers show

Comments

Frediano Ziglio - July 20, 2011, 7:57 a.m.
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
---
 block/qcow.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Patch

diff --git a/block/qcow.c b/block/qcow.c
index 8ccd7d7..007fb57 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -616,6 +616,7 @@  static int qcow_co_readv(BlockDriverState *bs, int64_t sector_num,
     if (acb.qiov->niov > 1) {
         qemu_iovec_from_buffer(acb.qiov, acb.orig_buf, acb.qiov->size);
         qemu_vfree(acb.orig_buf);
+        acb.orig_buf = NULL;
     }
 
     return ret;
@@ -700,6 +701,7 @@  static int qcow_co_writev(BlockDriverState *bs, int64_t sector_num,
 
     if (acb.qiov->niov > 1) {
         qemu_vfree(acb.orig_buf);
+        acb.orig_buf = NULL;
     }
 
     return ret;