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

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

 



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.

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