[PATCH 3/5] Free groups in case of a partial match

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

 



If there are more than two regexes, but only one of them matches,
the matched groups would be leaked.
---
 src/util/vircommand.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index c17792b..fab3aba 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -2858,10 +2858,10 @@ virCommandRunRegex(virCommandPtr cmd,
         if (i == nregex) {
             if (((*func)(groups, data)) < 0)
                 goto cleanup;
-
-            for (j = 0; j < totgroups; j++)
-                VIR_FREE(groups[j]);
         }
+
+        for (j = 0; j < ngroup; j++)
+            VIR_FREE(groups[j]);
     }
 
     ret = 0;
-- 
1.8.3.2

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