[libvirt] [PATCH] virsh-domain: Fix memleak in cmdUndefine with storage
Peter Krempa
pkrempa at redhat.com
Thu Aug 15 16:40:24 UTC 2013
On 08/12/13 17:25, Ján Tomko wrote:
> On 08/12/2013 04:13 PM, Peter Krempa wrote:
>> When undefining a domain with storage when the volume isn't managed by
>> libvirt the name and path strings weren't freed properly.
>>
>> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=996050
>> ---
>> tools/virsh-domain.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>
>> @@ -3090,6 +3092,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
>> }
>> vlist[nvols].source = source;
>> vlist[nvols].target = target;
>> + source = NULL;
>> + target = NULL;
>> nvols++;
>> }
>>
>
> Using VIR_APPEND_ELEMENT here might look nicer, but that's just cosmetic.
>
> However this patch is incomplete - there's also a leak of volume_tokens
> mentioned in the bug that you didn't address:
>
> ==19011== 10 bytes in 1 blocks are definitely lost in loss record 14 of 82
> ==19011== at 0x4A069EE: malloc (vg_replace_malloc.c:270)
> ==19011== by 0x38F0881041: strdup (in /lib64/libc-2.12.so)
> ==19011== by 0x40EB00: _vshStrdup (virsh.c:129)
> ==19011== by 0x40FC28: vshStringToArray (virsh.c:182)
> ==19011== by 0x414A66: cmdUndefine (virsh-domain.c:2609)
> ==19011== by 0x40D200: vshCommandRun (virsh.c:1652)
> ==19011== by 0x410964: main (virsh.c:3073)
>
> Maybe virStringSplit would give us an array that's easier to steal from?
I'll be addressing that issue in a separate refactor
>
> Jan
>
I pushed this patch according to Eric's ACK.
Thanks for the review.
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/20130815/cb135484/attachment-0001.sig>
More information about the libvir-list
mailing list