Subject: parser - fix memory leaks identified by valgrind tests

This patch fixes a few memory leaks found by valgrind. Most of these
occur in error cases and as such, are not a big deal. The dbus TOK_MODE
and flags TOK_CONDID leaks in parser_yacc.y are legitimate leaks,
if of very small amounts of memory.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Tyler Hicks <tyhicks@canonical.com>
This commit is contained in:
Steve Beattie 2013-09-11 02:10:31 -07:00
parent a1bf63dbe9
commit 93198cc7dd
3 changed files with 6 additions and 0 deletions

View file

@ -111,6 +111,7 @@ static int process_file_entries(struct codomain *cod)
PERROR(_("profile %s: has merged rule %s with "
"conflicting x modifiers\n"),
cod->name, cur->name);
free(table);
return 0;
}
//if (next->audit)

View file

@ -399,6 +399,7 @@ static int __expand_variable(struct symtab *symbol)
PERROR("Variable @{%s} is referenced recursively (by @{%s})\n",
split->var, symbol->var_name);
retval = 1;
free_values(this_value);
goto out;
}
@ -407,12 +408,14 @@ static int __expand_variable(struct symtab *symbol)
PERROR("Variable @{%s} references undefined variable @{%s}\n",
symbol->var_name, split->var);
retval = 3;
free_values(this_value);
goto out;
}
rc = __expand_variable(ref);
if (rc != 0) {
retval = rc;
free_values(this_value);
goto out;
}

View file

@ -436,6 +436,7 @@ opt_flags: { /* nothing */ $$ = 0; }
{
if (strcmp($1, "flags") != 0)
yyerror("expected flags= got %s=", $1);
free($1);
$$ = 1;
}
@ -1210,6 +1211,7 @@ dbus_perm: TOK_VALUE
| TOK_MODE
{
parse_dbus_mode($1, &$$, 1);
free($1);
}
dbus_perms: { /* nothing */ $$ = 0; }