]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
Fix the previous fix
authorMartin Josefsson <gandalf@wlug.westbo.se>
Mon, 5 May 2003 19:33:40 +0000 (19:33 +0000)
committerMartin Josefsson <gandalf@wlug.westbo.se>
Mon, 5 May 2003 19:33:40 +0000 (19:33 +0000)
No more segfaults or compilewarnings.

include/libiptc/libip6tc.h
ip6tables.c
iptables.c

index 2904db577af63148ebc86db1803735240c2cb373..7a247c46f7202b99de4f6d67d73659da086e201c 100644 (file)
@@ -26,6 +26,9 @@ int ip6tc_is_chain(const char *chain, const ip6tc_handle_t handle);
 /* Take a snapshot of the rules. Returns NULL on error. */
 ip6tc_handle_t ip6tc_init(const char *tablename);
 
+/* Cleanup after ip6tc_init(). */
+void ip6tc_free(ip6tc_handle_t *h);
+
 /* Iterator functions to run through the chains.  Returns NULL at end. */
 const char *ip6tc_first_chain(ip6tc_handle_t *handle);
 const char *ip6tc_next_chain(ip6tc_handle_t *handle);
index d250882506d78b2dafe9daaf7e04a481571cbdc2..17bdb4e517d8127bef371e1b8f28a42374f541cb 100644 (file)
@@ -1670,7 +1670,6 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
        const char *modprobe = NULL;
        int proto_used = 0;
        char icmp6p[] = "icmpv6";
-       int no_handle = 0;
 
        memset(&fw, 0, sizeof(fw));
 
@@ -2148,10 +2147,8 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
                           chain, IP6T_FUNCTION_MAXNAMELEN);
 
        /* only allocate handle if we weren't called with a handle */
-       if (!*handle) {
+       if (!*handle)
                *handle = ip6tc_init(*table);
-               no_handle = 1;
-       }
 
        if (!*handle) {
                /* try to insmod the module if iptc_init failed */
@@ -2296,8 +2293,5 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
        if (verbose > 1)
                dump_entries6(*handle);
 
-       if (no_handle)
-               ip6tc_free(handle);
-
        return ret;
 }
index b2de559ce0f7294ead9cc9473b8ef1ac1800c497..67d30c91b5aa4571f0637a4c918b5a4137436540 100644 (file)
@@ -1668,7 +1668,6 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle)
        char *protocol = NULL;
        const char *modprobe = NULL;
        int proto_used = 0;
-       int no_handle = 0;
 
        memset(&fw, 0, sizeof(fw));
 
@@ -2149,10 +2148,8 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle)
                           chain, IPT_FUNCTION_MAXNAMELEN);
 
        /* only allocate handle if we weren't called with a handle */
-       if (!*handle) {
+       if (!*handle)
                *handle = iptc_init(*table);
-               no_handle = 1;
-       }
 
        if (!*handle) {
                /* try to insmod the module if iptc_init failed */
@@ -2297,8 +2294,5 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle)
        if (verbose > 1)
                dump_entries(*handle);
 
-       if (no_handle)
-               iptc_free(handle);
-
        return ret;
 }