On 26.02.20 04:30, Pan Nengyuan wrote:
> 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.ro...@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengy...@huawei.com>
> ---
>  qemu-img.c | 2 ++
>  1 file changed, 2 insertions(+)

I think this should happen in the caller.  And there I think it would
make more sense to completely discard the old object and allocate a new one:

qapi_free_ImageCheck(check);
check = g_new0(ImageCheck, 1);

This way, we can’t forget to free any fields if new pointers were to be
added to the ImageCheck object.

Max

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to