[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] qemu-img: free memory before re-assign
From: |
Pan Nengyuan |
Subject: |
[PATCH 2/2] qemu-img: free memory before re-assign |
Date: |
Wed, 26 Feb 2020 11:30:37 +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>
---
qemu-img.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/qemu-img.c b/qemu-img.c
index 2b4562b9d9..bcbca6c9a2 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -638,6 +638,8 @@ static int collect_image_check(BlockDriverState *bs,
return ret;
}
+ g_free(check->filename);
+ g_free(check->format);
check->filename = g_strdup(filename);
check->format = g_strdup(bdrv_get_format_name(bs));
check->check_errors = result.check_errors;
--
2.18.2