Commit 40503ba5 authored by Matthieu Boutier's avatar Matthieu Boutier Committed by Juliusz Chroboczek

Fix parser memory leaks.

parent 4f4e3cba
......@@ -320,6 +320,17 @@ get_interface_type(int c, int *type_r, gnc_t gnc, void *closure)
return c;
}
static void
free_filter(struct filter *f)
{
free(f->ifname);
free(f->id);
free(f->prefix);
free(f->src_prefix);
free(f->neigh);
free(f->action.src_prefix);
free(f);
}
static int
parse_filter(int c, gnc_t gnc, void *closure, struct filter **filter_return)
......@@ -341,7 +352,7 @@ parse_filter(int c, gnc_t gnc, void *closure, struct filter **filter_return)
}
c = getword(c, &token, gnc, closure);
if(c < -1) {
free(filter);
free_filter(filter);
return -2;
}
......@@ -478,7 +489,7 @@ parse_filter(int c, gnc_t gnc, void *closure, struct filter **filter_return)
error:
free(token);
free(filter);
free_filter(filter);
return -2;
}
......@@ -619,6 +630,8 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
return c;
error:
if(if_conf->ifname)
free(if_conf->ifname);
free(if_conf);
return -2;
}
......@@ -711,6 +724,7 @@ add_ifconf(struct interface_conf *if_conf, struct interface_conf **if_confs)
while(next) {
if(strcmp(next->ifname, if_conf->ifname) == 0) {
merge_ifconf(next, if_conf, next);
free(if_conf->ifname);
free(if_conf);
if_conf = next;
goto done;
......@@ -732,6 +746,7 @@ flush_ifconf(struct interface_conf *if_conf)
{
if(if_conf == interface_confs) {
interface_confs = if_conf->next;
free(if_conf->ifname);
free(if_conf);
return;
} else {
......@@ -739,6 +754,7 @@ flush_ifconf(struct interface_conf *if_conf)
while(prev) {
if(prev->next == if_conf) {
prev->next = if_conf->next;
free(if_conf->ifname);
free(if_conf);
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment