Commit 8be332e7 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Avoid memory leak on error in parse_filter.

Noted by Matthieu Boutier.
parent 47c45341
......@@ -303,7 +303,7 @@ parse_filter(int c, gnc_t gnc, void *closure, struct filter **filter_return)
filter = calloc(1, sizeof(struct filter));
if(filter == NULL)
goto error;
return -2;
filter->plen_le = 128;
filter->src_plen_le = 128;
......@@ -314,8 +314,10 @@ parse_filter(int c, gnc_t gnc, void *closure, struct filter **filter_return)
break;
}
c = getword(c, &token, gnc, closure);
if(c < -1)
goto error;
if(c < -1) {
free(filter);
return -2;
}
if(strcmp(token, "ip") == 0) {
int af;
......@@ -449,6 +451,7 @@ parse_filter(int c, gnc_t gnc, void *closure, struct filter **filter_return)
return c;
error:
free(token);
free(filter);
return -2;
}
......
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