In a "for" loop there are created two new strings and they may not
be freed if a "target" string cannot be obtained. We have to free
the two created strings to prevent the memory leak.
This has been found by coverity.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
tools/virsh-domain-monitor.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index b29b82a..3a310df 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -560,6 +560,10 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
target = virXPathString("string(./target/@dev)", ctxt);
if (!target) {
vshError(ctl, "unable to query block list");
+ if (details) {
+ VIR_FREE(type);
+ VIR_FREE(device);
+ }
goto cleanup;
}
source = virXPathString("string(./source/@file"
--
1.8.3.1