mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
parser: pull forward free() calls
As noted by Seth Arnold, in expand_by_alternations() if our set variable has at least one value, then we're going to rewrite the entry, so rather than sprinkle the free()s near where the reallocation occurs, use one free() once we're guaranteed to need to do so. Signed-off-by: Steve Beattie <steve@nxnw.org> Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
78fe398a2f
commit
d4c8971b65
1 changed files with 2 additions and 2 deletions
|
@ -177,10 +177,11 @@ static int expand_by_alternations(struct set_value **valuelist,
|
|||
exit(1);
|
||||
}
|
||||
|
||||
free(*name);
|
||||
|
||||
value = get_next_set_value(valuelist);
|
||||
if (!value) {
|
||||
/* only one entry for the variable, so just sub it in */
|
||||
free(*name);
|
||||
if (asprintf(name, "%s%s%s",
|
||||
split_var->prefix ? split_var->prefix : "",
|
||||
first_value,
|
||||
|
@ -201,7 +202,6 @@ static int expand_by_alternations(struct set_value **valuelist,
|
|||
write_replacement(',', value, replacement, filter_leading_slash, filter_trailing_slash);
|
||||
}
|
||||
|
||||
free(*name);
|
||||
if (asprintf(name, "%s%s}%s",
|
||||
split_var->prefix ? split_var->prefix : "",
|
||||
replacement.c_str(),
|
||||
|
|
Loading…
Add table
Reference in a new issue