From df288236cd254798be3759fef4cbc3e535f5a1c3 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Mon, 31 Jan 2011 02:33:43 +0100 Subject: xtables: set custom opts to NULL on free 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 --- xtables.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xtables.c b/xtables.c index 00362992..be103d75 100644 --- 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, -- cgit v1.2.3