[PATCH] qemu_conf: clear domain before VIR_DELETE_ELEMENT

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

 



The macro VIR_DELETE_ELEMENT assume that the items being deleted have
already been cleared, so we must explicitly delete domain memory to
prevent a memory leak.

Signed-off-by: Xu Yandong <xuyandong2@xxxxxxxxxx>
---
 src/qemu/qemu_conf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 1aeec30f8a..db390d358e 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1620,10 +1620,12 @@ qemuSharedDeviceEntryRemove(virQEMUDriverPtr driver,
     if (!qemuSharedDeviceEntryDomainExists(entry, name, &idx))
         return 0;
 
-    if (entry->ref != 1)
+    if (entry->ref != 1) {
+        VIR_FREE(entry->domains[idx]);
         VIR_DELETE_ELEMENT(entry->domains, idx, entry->ref);
-    else
+    } else {
         ignore_value(virHashRemoveEntry(driver->sharedDevices, key));
+    }
 
     return 0;
 }
-- 
2.18.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]

  Powered by Linux