]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
qemu-img: free memory before re-assign
authorPan Nengyuan <pannengyuan@huawei.com>
Thu, 27 Feb 2020 01:29:50 +0000 (09:29 +0800)
committerMax Reitz <mreitz@redhat.com>
Wed, 11 Mar 2020 11:42:30 +0000 (12:42 +0100)
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>
qemu-img.c

index 4bc40df6d24af275eab8feaf05a6c9b13b2e8553..7b7087dd60326acdf7855c6b702bb22aa5550904 100644 (file)
@@ -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;