[libvirt] [PATCH] virsh-domain: Free dom before return false in cmdDump

Peter Krempa pkrempa at redhat.com
Wed Sep 25 11:49:13 UTC 2013


On 09/25/13 13:23, Ján Tomko wrote:
> On 09/25/2013 07:49 AM, Hongwei Bi wrote:
>>
>>
>> ---
>>  tools/virsh-domain.c |    4 +++-
>>  1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
>> index 856e888..f6d4edd 100644
>> --- a/tools/virsh-domain.c
>> +++ b/tools/virsh-domain.c
>> @@ -4487,8 +4487,10 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
>>      if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
>>          return false;
>>  
>> -    if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
>> +    if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) {
>> +        virDomainFree(dom);
>>          return false;
>> +    }
> 
> 'goto cleanup' would do the same and it's easier to read.
> 
> Alternatively, if we moved vshCommandOptStringReq before vshCommandOptDomain,
> 'return false' would be enough.

I'd prefer this option.

> 
> Jan

Peter


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130925/900ca838/attachment-0001.sig>


More information about the libvir-list mailing list