From: Andre Noll Date: Sat, 18 Jul 2009 12:00:17 +0000 (+0200) Subject: Fix a memory leak in filter.c. X-Git-Tag: v0.3.5~22 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=12b7063b97b9023def09300efc5eeda52971297b;p=paraslash.git Fix a memory leak in filter.c. We must free the filter configs as well. --- diff --git a/filter.c b/filter.c index 17b7f2fd..cc270172 100644 --- a/filter.c +++ b/filter.c @@ -61,6 +61,15 @@ static void open_filters(void) } } +static void free_filter_confs(void) +{ + int i; + struct filter_node *fn; + + FOR_EACH_FILTER_NODE(fn, fc, i) + free(fn->conf); +} + static int init_filter_chain(void) { int i, ret; @@ -69,7 +78,7 @@ static int init_filter_chain(void) if (!conf.filter_given) return -E_NO_FILTERS; fc->num_filters = conf.filter_given; - fc->filter_nodes = para_malloc(fc->num_filters * sizeof(struct filter_node)); + fc->filter_nodes = para_calloc(fc->num_filters * sizeof(struct filter_node)); fc->inbufp = &sit->buf; fc->in_loaded = &sit->loaded; fc->input_error = &sit->task.error; @@ -92,6 +101,7 @@ static int init_filter_chain(void) open_filters(); return 1; err: + free_filter_confs(); free(fc->filter_nodes); return ret; } @@ -180,6 +190,7 @@ int main(int argc, char *argv[]) s.default_timeout.tv_sec = 1; s.default_timeout.tv_usec = 0; ret = schedule(&s); + free_filter_confs(); close_filters(fc); out: free(sit->buf);