---
 src/iptables.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/iptables.c b/src/iptables.c
index eef91c1..fb38962 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -1299,6 +1299,23 @@ static struct xtables_target *prepare_target(struct 
connman_iptables *table,
                        xt_t->init(xt_t->t);
        }
 
+       if (xt_t == NULL)
+               return NULL;
+
+       iptables_globals.opts =
+               xtables_merge_options(
+#if XTABLES_VERSION_CODE > 5
+                               iptables_globals.orig_opts,
+#endif
+                               iptables_globals.opts,
+                               xt_t->extra_opts,
+                               &xt_t->option_offset);
+
+       if (iptables_globals.opts == NULL) {
+               g_free(xt_t->t);
+               xt_t = NULL;
+       }
+
        return xt_t;
 }
 
@@ -1544,17 +1561,6 @@ static int iptables_command(int argc, char *argv[])
                if (xt_t == NULL)
                        goto out;
 
-               iptables_globals.opts =
-                       xtables_merge_options(
-#if XTABLES_VERSION_CODE > 5
-                                       iptables_globals.orig_opts,
-#endif
-                                       iptables_globals.opts,
-                                       xt_t->extra_opts,
-                                       &xt_t->option_offset);
-               if (iptables_globals.opts == NULL)
-                       goto out;
-
                if (delete == TRUE) {
                        DBG("Deleting %s to %s (match %s)\n",
                                        target_name, chain, match_name);
-- 
1.7.7

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to