[PATCH v2] qemuDomainSaveInternal: fix memoryleak of virDomainDef

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

 



From: Zheng Chuan <zhengchuan@xxxxxxxxxx>

virDomainDefPtr 'def' is forgot to free after qemuDomainDefFormatLive(), fix it.

Signed-off-by: Zheng Chuan <zhengchuan@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 53980d4..2dafe7c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3356,18 +3356,15 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
      * is NULL or whether it was the live xml of the domain moments
      * before.  */
     if (xmlin) {
-        virDomainDefPtr def = NULL;
+        g_autoptr(virDomainDef) def = NULL;
 
         if (!(def = virDomainDefParseString(xmlin, driver->xmlopt,
                                             priv->qemuCaps,
                                             VIR_DOMAIN_DEF_PARSE_INACTIVE |
-                                            VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) {
+                                            VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
             goto endjob;
-        }
-        if (!qemuDomainCheckABIStability(driver, vm, def)) {
-            virDomainDefFree(def);
+        if (!qemuDomainCheckABIStability(driver, vm, def))
             goto endjob;
-        }
         xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, true, true);
     } else {
         xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def,
-- 
1.8.3.1




[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