Re: [PATCH 1/4] tests: plug memory leaks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/10/2010 01:07 PM, Laine Stump wrote:
>> +++ b/tests/qemuxml2argvtest.c
>> @@ -86,8 +86,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
>>       monitor_chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
>>       monitor_chr.data.nix.path = (char *)"/tmp/test-monitor";
>>       monitor_chr.data.nix.listen = 1;
>> -    if (!(monitor_chr.info.alias = strdup("monitor")))
>> -        goto fail;
>> +    monitor_chr.info.alias = (char *)"monitor";
>>
>>       flags = QEMUD_CMD_FLAG_VNC_COLON |
>>           QEMUD_CMD_FLAG_NO_REBOOT |
> 
> Well, to be totally safe and correct with this, you might instead want
> to create a function virDomainChrDefClear(),

test code would be the only client

 derived from
> virDomainChrDefFree(), and call that when you're done with monitor_chr
> (or just ALLOC monitor_chr instead of putting it on the stack, then call
> virDomainChrDefFree().

That idea crossed my head, then I noticed it would cause a bogus free()
of data.nix.path unless I turned that into a strdup() as well.

> 
> I'm okay with this fix anyway, as it stays within the spirit of the
> original code, and technically does fix the problem, so ACK.

Yep, definitely in the spirit of existing code.  Pushed as-is.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]