mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Merge Fix memory leak in aare_rules UniquePermsCache
When the find fails but the insertion also fails, we leak the new node that we generated. Delete the new node in this case to avoid leaking memory. The question remains, however, as to whether we should implement `operator==` in addition to `operator<` so that they are consistent with each other and `find` works correctly. Signed-off-by: Ryan Lee <ryan.lee@canonical.com> MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1399 Approved-by: Georgia Garcia <georgia.garcia@canonical.com> Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
commit
99261bad11
1 changed files with 3 additions and 1 deletions
|
@ -90,8 +90,10 @@ public:
|
|||
else
|
||||
node = new MatchFlag(priority, perms, audit);
|
||||
pair<iterator, bool> val = nodes.insert(make_pair(tmp, node));
|
||||
if (val.second == false)
|
||||
if (val.second == false) {
|
||||
delete node;
|
||||
return val.first->second;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
return res->second;
|
||||
|
|
Loading…
Add table
Reference in a new issue