[libvirt] [PATCH 6/6] vbox: Don't leak domain names in vboxListDefinedDomains
Matthias Bolte
matthias.bolte at googlemail.com
Fri Dec 17 22:24:04 UTC 2010
2010/12/17 Eric Blake <eblake at redhat.com>:
> 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
More information about the libvir-list
mailing list