Patchwork [07/10] vmdk: fix double free

login
register
mail settings
Submitter Juan Quintela
Date March 4, 2010, 9 a.m.
Message ID <315b904b5627115bda0e92dde097be4673298c5e.1267692963.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/46902/
State New
Headers show

Comments

Juan Quintela - March 4, 2010, 9 a.m.
fail_gd error case would also free rgd_buf that was already freed

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 block/vmdk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/block/vmdk.c b/block/vmdk.c
index 67a690e..819c1c9 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -315,7 +315,6 @@  static int vmdk_snapshot_create(const char *filename, const char *backing_file)
         ret = -errno;
         goto fail_rgd;
     }
-    qemu_free(rgd_buf);

     /* write GD */
     gd_buf = qemu_malloc(gd_size);
@@ -336,6 +335,7 @@  static int vmdk_snapshot_create(const char *filename, const char *backing_file)
         goto fail_gd;
     }
     qemu_free(gd_buf);
+    qemu_free(rgd_buf);

     close(p_fd);
     close(snp_fd);