]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables: set custom opts to NULL on free
authorJan Engelhardt <jengelh@medozas.de>
Mon, 31 Jan 2011 01:33:43 +0000 (02:33 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Mon, 31 Jan 2011 01:36:51 +0000 (02:36 +0100)
When inside ip6tables-restore, xtables_free_opts can be called
multiple times, especially when trying to exit with an error message
from outside do_command. So set it to NULL so that we do not attempt
to free a dangling pointer.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
xtables.c

index 00362992f848a5876d465fcffccca44d59ff8497..be103d7516693d40567fc8f0c6d89778a04eb3a4 100644 (file)
--- a/xtables.c
+++ b/xtables.c
@@ -75,8 +75,10 @@ void basic_exit_err(enum xtables_exittype status, const char *msg, ...)
 
 void xtables_free_opts(int unused)
 {
-       if (xt_params->opts != xt_params->orig_opts)
+       if (xt_params->opts != xt_params->orig_opts) {
                free(xt_params->opts);
+               xt_params->opts = NULL;
+       }
 }
 
 struct option *xtables_merge_options(struct option *orig_opts,