diff mbox

[alt,3/7] qemu-img: Fix insignifcant memleak

Message ID 1406402531-9278-4-git-send-email-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz July 26, 2014, 7:22 p.m. UTC
As soon as options is set in img_amend(), it needs to be freed before
the function returns. This leak is rather insignifcant, as qemu-img will
exit subsequently anyway, but there's no point in not fixing it.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 qemu-img.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Eric Blake July 30, 2014, 2:58 p.m. UTC | #1
On 07/26/2014 01:22 PM, Max Reitz wrote:
> As soon as options is set in img_amend(), it needs to be freed before
> the function returns. This leak is rather insignifcant, as qemu-img will

s/insignifcant/insignificant/

> exit subsequently anyway, but there's no point in not fixing it.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  qemu-img.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

1-3 look the same as in the other version of this series, so no further
comments on them. I'll try and review both series to see if either one
makes more sense as being more desirable.
Max Reitz July 30, 2014, 8:08 p.m. UTC | #2
On 30.07.2014 16:58, Eric Blake wrote:
> On 07/26/2014 01:22 PM, Max Reitz wrote:
>> As soon as options is set in img_amend(), it needs to be freed before
>> the function returns. This leak is rather insignifcant, as qemu-img will
> s/insignifcant/insignificant/

I wonder how I was able to get it wrong the same way twice...

>> exit subsequently anyway, but there's no point in not fixing it.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>   qemu-img.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
> 1-3 look the same as in the other version of this series, so no further
> comments on them. I'll try and review both series to see if either one
> makes more sense as being more desirable.

Thank you,

Max
Benoît Canet July 31, 2014, 7:59 a.m. UTC | #3
The Saturday 26 Jul 2014 à 21:22:07 (+0200), Max Reitz wrote :

> As soon as options is set in img_amend(), it needs to be freed before
> the function returns. This leak is rather insignifcant, as qemu-img will
> exit subsequently anyway, but there's no point in not fixing it.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  qemu-img.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index a06f425..d73a68a 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -2809,7 +2809,9 @@ static int img_amend(int argc, char **argv)
>      }
>  
>      if (optind != argc - 1) {
> -        error_exit("Expecting one image file name");
> +        error_report("Expecting one image file name");
> +        ret = -1;
> +        goto out;
>      }
>  
>      flags = BDRV_O_FLAGS | BDRV_O_RDWR;
> -- 
> 2.0.3
> 
> 

Reviewed-by: Benoit Canet <benoit@irqsave.net>
diff mbox

Patch

diff --git a/qemu-img.c b/qemu-img.c
index a06f425..d73a68a 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2809,7 +2809,9 @@  static int img_amend(int argc, char **argv)
     }
 
     if (optind != argc - 1) {
-        error_exit("Expecting one image file name");
+        error_report("Expecting one image file name");
+        ret = -1;
+        goto out;
     }
 
     flags = BDRV_O_FLAGS | BDRV_O_RDWR;