]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
iptables-xml: Free allocated chain strings
authorPhil Sutter <phil@nwl.cc>
Fri, 25 Nov 2022 18:30:09 +0000 (19:30 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 2 Dec 2022 00:44:17 +0000 (01:44 +0100)
Freeing only if 'created' is non-zero is wrong - the data was still
allocated. In fact, the field is supposed to prevent only the call to
openChain().

Fixes: 8d3eccb19a9c6 ("Add iptables-xml tool (Amin Azez <azez@ufomechanic.net>)")
Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/iptables-xml.c

index d28cf7481b55df87f0d41a04d212e14c3f29e9b8..396c0a123ea089940f0617e7e5718fb2caf35259 100644 (file)
@@ -225,13 +225,13 @@ finishChains(void)
 {
        int c;
 
-       for (c = 0; c < nextChain; c++)
-               if (!chains[c].created) {
+       for (c = 0; c < nextChain; c++) {
+               if (!chains[c].created)
                        openChain(chains[c].chain, chains[c].policy,
                                  &(chains[c].count), '/');
-                       free(chains[c].chain);
-                       free(chains[c].policy);
-               }
+               free(chains[c].chain);
+               free(chains[c].policy);
+       }
        nextChain = 0;
 }