From 1cd6dc33d533d05f5212f215521d5c3c9e362714 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 28 Nov 2008 00:45:06 +0100 Subject: conntrack: move release options code to free_options() This patch move the options release to free_options(). It also move the free_options call after the error checking because exit_error already free the option. Signed-off-by: Pablo Neira Ayuso --- src/conntrack.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/conntrack.c') diff --git a/src/conntrack.c b/src/conntrack.c index e165144..8946ec8 100644 --- a/src/conntrack.c +++ b/src/conntrack.c @@ -223,18 +223,21 @@ exit_tryhelp(int status) exit(status); } -void __attribute__((noreturn)) -exit_error(enum exittype status, const char *msg, ...) +static void free_options(void) { - va_list args; - - /* On error paths, make sure that we don't leak the memory - * reserved during options merging */ if (opts != original_opts) { free(opts); opts = original_opts; global_option_offset = 0; } +} + +void __attribute__((noreturn)) +exit_error(enum exittype status, const char *msg, ...) +{ + va_list args; + + free_options(); va_start(args, msg); fprintf(stderr,"%s v%s (conntrack-tools): ", PROGNAME, VERSION); vfprintf(stderr, msg, args); @@ -1333,16 +1336,12 @@ int main(int argc, char *argv[]) break; } - if (opts != original_opts) { - free(opts); - opts = original_opts; - global_option_offset = 0; - } - if (res < 0) exit_error(OTHER_PROBLEM, "Operation failed: %s", err2str(errno, command)); + free_options(); + if (exit_msg[cmd][0]) { fprintf(stderr, "%s v%s (conntrack-tools): ",PROGNAME,VERSION); fprintf(stderr, exit_msg[cmd], counter); -- cgit v1.2.3