summaryrefslogtreecommitdiffstats
path: root/qemu-img.c
diff options
context:
space:
mode:
authorPan Nengyuan2020-02-27 02:29:50 +0100
committerMax Reitz2020-03-11 12:42:30 +0100
commitfc124ea1dbfac2a1d5b851596831c9da746b7b66 (patch)
tree4d4a219616e234bd68fa70722e7ba1d7f54d52e1 /qemu-img.c
parentblock/qcow2: do free crypto_opts in qcow2_close() (diff)
downloadqemu-fc124ea1dbfac2a1d5b851596831c9da746b7b66.tar.gz
qemu-fc124ea1dbfac2a1d5b851596831c9da746b7b66.tar.xz
qemu-fc124ea1dbfac2a1d5b851596831c9da746b7b66.zip
qemu-img: free memory before re-assign
collect_image_check() is called twice in img_check(), the filename/format will be alloced without free the original memory. It is not a big deal since the process will exit anyway, but seems like a clean code and it will remove the warning spotted by asan. Reported-by: Euler Robot <euler.robot@huawei.com> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> Message-Id: <20200227012950.12256-3-pannengyuan@huawei.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 4bc40df6d2..7b7087dd60 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -817,6 +817,8 @@ static int img_check(int argc, char **argv)
check->corruptions_fixed);
}
+ qapi_free_ImageCheck(check);
+ check = g_new0(ImageCheck, 1);
ret = collect_image_check(bs, check, filename, fmt, 0);
check->leaks_fixed = leaks_fixed;