summaryrefslogtreecommitdiffstats
path: root/src/conntrack.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-11-28 00:45:06 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2008-11-28 00:45:06 +0100
commit1cd6dc33d533d05f5212f215521d5c3c9e362714 (patch)
tree4f04456a5222756e35d3723c1ab7f1e61a03e4f7 /src/conntrack.c
parenta81b65aee06b864772647d9ec0ee09fdaccf2889 (diff)
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 <pablo@netfilter.org>
Diffstat (limited to 'src/conntrack.c')
-rw-r--r--src/conntrack.c23
1 files changed, 11 insertions, 12 deletions
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);