[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/2] qemu-img: free memory before re-assign
From: |
Pan Nengyuan |
Subject: |
[PATCH v2 2/2] qemu-img: free memory before re-assign |
Date: |
Thu, 27 Feb 2020 09:29:50 +0800 |
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 <address@hidden>
Signed-off-by: Pan Nengyuan <address@hidden>
---
v2->v1:
- Instead of freeing part of props in collect_image_check(), do discard the old
check object and allocate a new one in the caller to make more sense.(suggested
by Max Reitz)
---
qemu-img.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/qemu-img.c b/qemu-img.c
index 804630a368..a824b8576a 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;
--
2.18.2