]> xenbits.xensource.com Git - libvirt.git/commitdiff
Free groups in case of a partial match
authorJán Tomko <jtomko@redhat.com>
Thu, 20 Mar 2014 12:08:49 +0000 (13:08 +0100)
committerJán Tomko <jtomko@redhat.com>
Wed, 26 Mar 2014 14:06:10 +0000 (15:06 +0100)
If there are more than two regexes, but only one of them matches,
the matched groups would be leaked.

src/util/vircommand.c

index 8a288133527258c0ed7cc7418475509db5adf7e3..acf63b320e6d1cc1138157f12ede72bd43500d0c 100644 (file)
@@ -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;