Re: [PATCH 6/6] vbox: Don't leak domain names in vboxListDefinedDomains

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

 



2010/12/17 Eric Blake <eblake@xxxxxxxxxx>:
> On 12/17/2010 11:56 AM, Matthias Bolte wrote:
>> ---
>> Âsrc/vbox/vbox_tmpl.c | Â Â8 +++++---
>> Â1 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
>> index c283609..728c501 100644
>> --- a/src/vbox/vbox_tmpl.c
>> +++ b/src/vbox/vbox_tmpl.c
>> @@ -3112,13 +3112,17 @@ static int vboxListDefinedDomains(virConnectPtr conn, char ** const names, int m
>> Â Â Â Â Â Â Â Â Â Â Â|| (state > MachineState_LastOnline) ) {
>> Â Â Â Â Â Â Â Â Â Â Âmachine->vtbl->GetName(machine, &machineNameUtf16);
>> Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_TO_UTF8(machineNameUtf16, &machineName);
>> - Â Â Â Â Â Â Â Â Â Âif (!(names[j++] = strdup(machineName))) {
>> + Â Â Â Â Â Â Â Â Â Ânames[j] = strdup(machineName);
>> + Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(machineNameUtf16);
>> + Â Â Â Â Â Â Â Â Â ÂVBOX_UTF8_FREE(machineName);
>> + Â Â Â Â Â Â Â Â Â Âif (!names[j]) {
>> Â Â Â Â Â Â Â Â Â Â Â Â ÂvirReportOOMError();
>> Â Â Â Â Â Â Â Â Â Â Â Â Âfor ( ; j >= 0 ; j--)
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂVIR_FREE(names[j]);
>> Â Â Â Â Â Â Â Â Â Â Â Â Âret = -1;
>> Â Â Â Â Â Â Â Â Â Â Â Â Âgoto cleanup;
>> Â Â Â Â Â Â Â Â Â Â Â}
>> + Â Â Â Â Â Â Â Â Â Âj++;
>
> ACK - since machineName is reused each iteration of the loop, it has to
> be freed each iteration rather than once at the end.
>

Thanks, pushed.

Matthias

--
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]