[PATCH] Fix memory leak while scanning snapshots

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

 



If a snapshot with the name already exists, virDomainSnapshotAssignDef()
just returns NULL, in which case the snapshot definition is leaked.
Currently this leak is not a big problem, since qemuDomainSnapshotLoad()
is only called once during initial startup of libvirtd.

Signed-off-by: Philipp Hahn <hahn@xxxxxxxxxxxxx>
---
 src/qemu/qemu_driver.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ce19be7..b815046 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -293,6 +293,7 @@ static void qemuDomainSnapshotLoad(void *payload,
     int ret;
     char *fullpath;
     virDomainSnapshotDefPtr def = NULL;
+    virDomainSnapshotObjPtr snap = NULL;
     char ebuf[1024];
 
     virDomainObjLock(vm);
@@ -344,7 +345,10 @@ static void qemuDomainSnapshotLoad(void *payload,
             continue;
         }
 
-        virDomainSnapshotAssignDef(&vm->snapshots, def);
+        snap = virDomainSnapshotAssignDef(&vm->snapshots, def);
+        if (snap == NULL) {
+            virDomainSnapshotDefFree(def);
+        }
 
         VIR_FREE(fullpath);
         VIR_FREE(xmlStr);
-- 
1.7.1

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