tools: Move iptables_test target options merge in prepare_target
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Thu, 27 Oct 2011 07:24:46 +0000 (10:24 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 28 Oct 2011 19:26:12 +0000 (21:26 +0200)
tools/iptables-test.c

index a29a1a0..5ee1ec3 100644 (file)
@@ -1289,6 +1289,20 @@ static struct xtables_target *prepare_target(struct connman_iptables *table,
                        xt_t->init(xt_t->t);
        }
 
+       connman_iptables_globals.opts =
+               xtables_merge_options(
+#if XTABLES_VERSION_CODE > 5
+                               connman_iptables_globals.orig_opts,
+#endif
+                               connman_iptables_globals.opts,
+                               xt_t->extra_opts,
+                               &xt_t->option_offset);
+
+       if (connman_iptables_globals.opts == NULL) {
+               g_free(xt_t->t);
+               xt_t = NULL;
+       }
+
        return xt_t;
 }
 
@@ -1530,17 +1544,6 @@ int main(int argc, char *argv[])
                if (xt_t == NULL)
                        goto out;
 
-               connman_iptables_globals.opts =
-                       xtables_merge_options(
-#if XTABLES_VERSION_CODE > 5
-                                       connman_iptables_globals.orig_opts,
-#endif
-                                       connman_iptables_globals.opts,
-                                       xt_t->extra_opts,
-                                       &xt_t->option_offset);
-               if (connman_iptables_globals.opts == NULL)
-                       goto out;
-
                if (delete_rule == TRUE) {
                        printf("Deleting %s to %s (match %s)\n", target_name,
                                        chain, match_name);