[PATCH 4/6] qemu: fix memleak in virCapabilitiesDomainDataLookup

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

 



virBufferContentAndReset() doesn't free buf contents, we should use
virBufferFreeAndReset() to get buf freed.

Signed-off-by: Zhang Bo <oscar.zhangbo@xxxxxxxxxx>
---
 src/conf/capabilities.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 2c674a8..922741f 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -701,13 +701,14 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps,
             !virBufferCurrentContent(&buf)[0])
             virBufferAsprintf(&buf, "%s", _("any configuration"));
         if (virBufferCheckError(&buf) < 0) {
-            virBufferContentAndReset(&buf);
+            virBufferFreeAndReset(&buf);
             goto error;
         }
 
         virReportError(VIR_ERR_INVALID_ARG,
                        _("could not find capabilities for %s"),
-                       virBufferContentAndReset(&buf));
+                       virBufferCurrentContent(&buf));
+        virBufferFreeAndReset(&buf);
         goto error;
     }
 
-- 
1.7.12.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]