[libvirt] [PATCH 6/6] vbox: Don't leak domain names in vboxListDefinedDomains
Eric Blake
eblake at redhat.com
Fri Dec 17 20:34:35 UTC 2010
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 at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101217/62798abf/attachment-0001.sig>
More information about the libvir-list
mailing list