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

Re: [libvirt] [PATCH 3/4] qemu: plug memory leak



On 12/10/2010 02:18 PM, Eric Blake wrote:
* src/qemu/qemu_conf.c (qemudBuildCommandLine): Don't leak
rbd_hosts.
---

Leak introduced post-0.8.6.

  src/qemu/qemu_conf.c |    8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index fb0b29a..4f19037 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -4765,8 +4765,11 @@ qemudBuildCommandLine(virConnectPtr conn,
          virBufferFreeAndReset(&rbd_hosts);
          goto no_memory;
      }
-    if (has_rbd_hosts)
-        virCommandAddEnvPair(cmd, "CEPH_ARGS", virBufferContentAndReset(&rbd_hosts));
+    if (has_rbd_hosts) {
+        char *optstr = virBufferContentAndReset(&rbd_hosts);
+        virCommandAddEnvPair(cmd, "CEPH_ARGS", optstr);
+        VIR_FREE(optstr);
+    }

      if (qemuCmdFlags&  QEMUD_CMD_FLAG_FSDEV) {
          for (i = 0 ; i<  def->nfss ; i++) {
@@ -5516,6 +5519,7 @@ qemudBuildCommandLine(virConnectPtr conn,
   error:
      for (i = 0; i<= last_good_net; i++)
          virDomainConfNWFilterTeardown(def->nets[i]);
+    virBufferFreeAndReset(&rbd_hosts);
      virCommandFree(cmd);
      return NULL;
  }

ACK


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