Without this patch, running make check would trigger this minor leak:
10 bytes in 1 blocks are definitely lost in loss record 1 of 20
at 0x4A0739E: malloc (vg_replace_malloc.c:207)
by 0x3F872808A1: strdup (strdup.c:43)
by 0x4CA2503: qemudLoadDriverConfig (qemu_conf.c:70)
by 0x4CA7EA7: qemudStartup (qemu_driver.c:216)
by 0x4C3AEBC: __virStateInitialize (libvirt.c:592)
by 0x4096B6: qemudInitialize (qemud.c:738)
by 0x40CCCF: main (qemud.c:2216)
Looking into it, I found there were actually two separate leaks
and an erroneous diagnostic. This fixes them:
From b1f17b05e59cf12aa3f73fde1be713dbadf02f76 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 5 Nov 2008 14:50:24 +0100
Subject: [PATCH] plug two leaks and fix a diagnostic
* src/qemu_conf.c (qemudLoadDriverConfig): Don't leak ->vncListen.
Fix an erroneous copy-and-pasted diagnostic.
* src/qemu_driver.c (qemudShutdown): Don't leak another ->vncListen.
---
src/qemu_conf.c | 3 ++-
src/qemu_driver.c | 1 +
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 54ac23d..0e3b959 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -118,9 +118,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
p = virConfGetValue (conf, "vnc_listen");
CHECK_TYPE ("vnc_listen", VIR_CONF_STRING);
if (p && p->str) {
+ VIR_FREE(driver->vncListen);
if (!(driver->vncListen = strdup(p->str))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "%s", _("failed to allocate
vncTLSx509certdir"));
+ "%s", _("failed to allocate
vnc_listen"));
virConfFree(conf);
return -1;
}
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 4adeb73..5d108ed 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -314,6 +314,7 @@ qemudShutdown(void) {
VIR_FREE(qemu_driver->configDir);
VIR_FREE(qemu_driver->autostartDir);
VIR_FREE(qemu_driver->vncTLSx509certdir);
+ VIR_FREE(qemu_driver->vncListen);
/* Free domain callback list */
virDomainEventCallbackListFree(qemu_driver->domainEventCallbacks);
--
1.6.0.3.756.gb776d