[PATCH 03/22] bhyveConnectDomainXMLToNative: Fix memory leak in incorrect virCommandToString usage

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

 



virCommandToString returns an allocated buffer, so using it directly as
argument of virBufferAdd which doesn't consume the string causes it to
be leaked. Switch to virBufferToStringBuf since we are already using a
buffer.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/bhyve/bhyve_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 0fddf9533b..fc696a50a7 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -723,14 +723,14 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
                                                     "<device.map>", NULL)))
             goto cleanup;

-        virBufferAdd(&buf, virCommandToString(loadcmd, false), -1);
+        virBufferToStringBuf(loadcmd, &buf, false, false);
         virBufferAddChar(&buf, '\n');
     }

     if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))
         goto cleanup;

-    virBufferAdd(&buf, virCommandToString(cmd, false), -1);
+    virBufferToStringBuf(cmd, &buf, false, false);

     ret = virBufferContentAndReset(&buf);

-- 
2.31.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