From 3ced80b54a0814a31da5b97e9d55b1c11daf8f76 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Fri, 4 Sep 2009 15:38:15 +0200 Subject: [PATCH] Fix a memory leak in virsh * src/virsh.c: cmdNodeDeviceDumpXML wasn't freeing virNodeDeviceGetXMLDesc() return string --- src/virsh.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/virsh.c b/src/virsh.c index 15e0cef510..910d8600f9 100644 --- a/src/virsh.c +++ b/src/virsh.c @@ -5521,6 +5521,7 @@ cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd) { const char *name; virNodeDevicePtr device; + char *xml; if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) return FALSE; @@ -5531,7 +5532,14 @@ cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd) return FALSE; } - vshPrint(ctl, "%s\n", virNodeDeviceGetXMLDesc(device, 0)); + xml = virNodeDeviceGetXMLDesc(device, 0); + if (!xml) { + virNodeDeviceFree(device); + return FALSE; + } + + vshPrint(ctl, "%s\n", xml); + free(xml); virNodeDeviceFree(device); return TRUE; } -- GitLab