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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]