Skip to content

Commit

Permalink
cfgparser: fix some memory leaks
Browse files Browse the repository at this point in the history
Coverity:
CID 739682 (#1 of 2): Resource leak (RESOURCE_LEAK)
At (84): Variable "in" going out of scope leaks the storage it points to.
CID 739682 (#2 of 2): Resource leak (RESOURCE_LEAK)
At (89): Variable "in" going out of scope leaks the storage it points to.

Signed-off-by: Ferry Huberts <[email protected]>
  • Loading branch information
fhuberts committed Oct 23, 2012
1 parent 9cbfc68 commit 5799fb1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cfgparser/oparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ ifdblock: TOK_INTERFACE_DEFAULTS

if (in->cnf == NULL || in->cnfi == NULL) {
fprintf(stderr, "Out of memory(ADD DEFIFRULE)\n");
if (in->cnf) {
free(in->cnf);
}
if (in->cnfi) {
free(in->cnfi);
}
free(in);
YYABORT;
}

Expand Down Expand Up @@ -965,13 +972,15 @@ ifnick: TOK_STRING
in->cnf = malloc(sizeof(*in->cnf));
if (in->cnf == NULL) {
fprintf(stderr, "Out of memory(ADD IFRULE)\n");
free(in);
YYABORT;
}
memset(in->cnf, 0x00, sizeof(*in->cnf));

in->cnfi = malloc(sizeof(*in->cnfi));
if (in->cnf == NULL) {
fprintf(stderr, "Out of memory(ADD IFRULE)\n");
free(in);
YYABORT;
}
memset(in->cnfi, 0xFF, sizeof(*in->cnfi));
Expand Down

0 comments on commit 5799fb1

Please sign in to comment.