]> xenbits.xensource.com Git - libvirt.git/commitdiff
Give virNWFilterVarCombIterNext saner semantics
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 17 Mar 2014 11:38:20 +0000 (11:38 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 17 Mar 2014 17:08:54 +0000 (17:08 +0000)
The virNWFilterVarCombIterNext method will free its
parameter when it gets to the end of the iterator.
This is somewhat misleading design, making it appear
as if the caller has a memory leak. Remove the free'ing
of the parameter and ensure that the calling method
ebiptablesCreateRuleInstanceIterate free's it instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/conf/nwfilter_params.c
src/nwfilter/nwfilter_ebiptables_driver.c

index a78c4078499b0e7afd0a9268118062cfcdff444e..539313431d58ddfaff84c9740374d86a17c78ddb 100644 (file)
@@ -526,10 +526,8 @@ next:
         }
     }
 
-    if (ci->nIter == i) {
-        virNWFilterVarCombIterFree(ci);
+    if (ci->nIter == i)
         return NULL;
-    }
 
     return ci;
 }
index d0acb236582a31329f4a227ab46d5f91ab403f0b..74a1f9dfab91db6c1f663ced795370ab15380e96 100644 (file)
@@ -2772,14 +2772,14 @@ ebiptablesCreateRuleInstanceIterate(
                              virNWFilterRuleInstPtr res)
 {
     int rc = 0;
-    virNWFilterVarCombIterPtr vciter;
+    virNWFilterVarCombIterPtr vciter, tmp;
 
     /* rule->vars holds all the variables names that this rule will access.
      * iterate over all combinations of the variables' values and instantiate
      * the filtering rule with each combination.
      */
-    vciter = virNWFilterVarCombIterCreate(vars,
-                                          rule->varAccess, rule->nVarAccess);
+    tmp = vciter = virNWFilterVarCombIterCreate(vars,
+                                                rule->varAccess, rule->nVarAccess);
     if (!vciter)
         return -1;
 
@@ -2788,12 +2788,12 @@ ebiptablesCreateRuleInstanceIterate(
                                           nwfilter,
                                           rule,
                                           ifname,
-                                          vciter,
+                                          tmp,
                                           res);
         if (rc < 0)
             break;
-        vciter = virNWFilterVarCombIterNext(vciter);
-    } while (vciter != NULL);
+        tmp = virNWFilterVarCombIterNext(tmp);
+    } while (tmp != NULL);
 
     virNWFilterVarCombIterFree(vciter);