[libvirt] [PATCH 4/6] Fix possible memory leak in virsh-domain-monitor.c

Pavel Hrdina phrdina at redhat.com
Mon Jan 13 16:12:10 UTC 2014


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 at 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




More information about the libvir-list mailing list