]> git.tue.mpg.de Git - paraslash.git/commitdiff
Fix a memory leak in filter.c.
authorAndre Noll <maan@systemlinux.org>
Sat, 18 Jul 2009 12:00:17 +0000 (14:00 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 18 Jul 2009 12:00:17 +0000 (14:00 +0200)
We must free the filter configs as well.

filter.c

index 17b7f2fdd938678431e5a294071602807ebdd3e2..cc270172ba6073c282564a92646531e53eee5f7a 100644 (file)
--- 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);