Here's the patch (entire function below):
From 1ee0edab5356ca8cd84a88e4e4a2e4f3cd916f57 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 16 Feb 2010 08:22:34 +0100
Subject: [PATCH] qemuMonitorTextAddDevice: avoid unconditional leak
* src/qemu/qemu_monitor_text.c (qemuMonitorTextAddDevice): Free the
device name buffer.
---
src/qemu/qemu_monitor_text.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index e993699..c71bf1d 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -2087,6 +2087,7 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon,
cleanup:
VIR_FREE(cmd);
VIR_FREE(reply);
+ VIR_FREE(safedev);
return ret;
}
--
1.7.0.181.g41533
For reference, here's the entire function:
int qemuMonitorTextAddDevice(qemuMonitorPtr mon,
const char *devicestr)
{
char *cmd = NULL;
char *reply = NULL;
char *safedev;
int ret = -1;
if (!(safedev = qemuMonitorEscapeArg(devicestr))) {
virReportOOMError();
goto cleanup;
}
if (virAsprintf(&cmd, "device_add %s", safedev) < 0) {
virReportOOMError();
goto cleanup;
}
if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("cannot attach %s device"), devicestr);
goto cleanup;
}
if (STRNEQ(reply, "")) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("adding %s device failed: %s"), devicestr, reply);
goto cleanup;
}
ret = 0;
cleanup:
VIR_FREE(cmd);
VIR_FREE(reply);
VIR_FREE(safedev);
return ret;
}