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

Ján Tomko jtomko at redhat.com
Tue Mar 25 07:17:50 UTC 2014


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




More information about the libvir-list mailing list