From 9ca92b91c68fb59989f317fea5e7c5e36cab7458 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 20 Apr 2008 20:55:15 +0200 Subject: [PATCH] filter.c: Handle filter errors gracefully. Free the filter chain struct on errors and do not try to close filters that haven't been opened. --- filter.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/filter.c b/filter.c index ed168c39..16204393 100644 --- a/filter.c +++ b/filter.c @@ -75,7 +75,7 @@ static int init_filter_chain(void) fn = fc->filter_nodes + i; ret = check_filter_arg(fa, &fn->conf); if (ret < 0) - return ret; + goto err; fn->filter_num = ret; fn->fc = fc; INIT_LIST_HEAD(&fn->callbacks); @@ -83,6 +83,9 @@ static int init_filter_chain(void) } open_filters(); return 1; +err: + free(fc->filter_nodes); + return ret; } static int parse_config(int argc, char *argv[]) @@ -159,9 +162,9 @@ int main(int argc, char *argv[]) s.default_timeout.tv_sec = 1; s.default_timeout.tv_usec = 0; ret = schedule(&s); + close_filters(fc); out: free(sit->buf); - close_filters(fc); if (ret < 0) PARA_EMERG_LOG("%s\n", para_strerror(-ret)); return ret < 0? EXIT_FAILURE : EXIT_SUCCESS; -- 2.39.5