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