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

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



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

Signed-off-by: Zhang Bo <oscar zhangbo huawei com>
---
 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



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