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

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

 



---
 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++;
                     ret++;
                 }
             }
@@ -3126,8 +3130,6 @@ static int vboxListDefinedDomains(virConnectPtr conn, char ** const names, int m
     }
 
 cleanup:
-    VBOX_UTF8_FREE(machineName);
-    VBOX_UTF16_FREE(machineNameUtf16);
     vboxArrayRelease(&machines);
     return ret;
 }
-- 
1.7.0.4

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