[PATCH 1/6] vbox: Fix resource leak

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

 



Need to free the allocated hardDiskToOpen array. The contents of the
array are just pointers returned by virVBoxSnapshotConfHardDiskByLocation
and not allocated AFAICT so they don't need to also be freed as well.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/vbox/vbox_common.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 72a24a3464..0e7fe06748 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -4627,6 +4627,8 @@ vboxSnapshotRedefine(virDomainPtr dom,
     int realReadOnlyDisksPathSize = 0;
     virVBoxSnapshotConfSnapshotPtr newSnapshotPtr = NULL;
     unsigned char snapshotUuid[VIR_UUID_BUFLEN];
+    virVBoxSnapshotConfHardDiskPtr *hardDiskToOpen = NULL;
+    size_t hardDiskToOpenSize = 0;
     char **searchResultTab = NULL;
     ssize_t resultSize = 0;
     int it = 0;
@@ -5080,8 +5082,6 @@ vboxSnapshotRedefine(virDomainPtr dom,
      */
     for (it = 0; it < def->dom->ndisks; it++) {
         char *location = NULL;
-        virVBoxSnapshotConfHardDiskPtr *hardDiskToOpen = NULL;
-        size_t hardDiskToOpenSize = 0;
 
         location = def->dom->disks[it]->src->path;
         if (!location)
@@ -5394,8 +5394,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
         if (!location)
             goto cleanup;
 
-        virVBoxSnapshotConfHardDiskPtr *hardDiskToOpen = NULL;
-        size_t hardDiskToOpenSize = virVBoxSnapshotConfDiskListToOpen(snapshotMachineDesc,
+        hardDiskToOpenSize = virVBoxSnapshotConfDiskListToOpen(snapshotMachineDesc,
                                                    &hardDiskToOpen, location);
         for (jt = 0; jt < hardDiskToOpenSize; jt++) {
             IMedium *medium = NULL;
@@ -5459,6 +5458,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
     virStringListFree(realReadOnlyDisksPath);
     virStringListFree(realReadWriteDisksPath);
     virStringListFree(searchResultTab);
+    VIR_FREE(hardDiskToOpen);
     VIR_FREE(newSnapshotPtr);
     VIR_FREE(machineLocationPath);
     VIR_FREE(nameTmpUse);
-- 
2.14.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]

  Powered by Linux