2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-28 21:07:56 +00:00

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.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
This commit is contained in:
Ryan Lee 2024-10-18 16:27:44 -07:00
parent 8d6270e1fe
commit 81950dae4e

View File

@ -90,8 +90,10 @@ public:
else else
node = new MatchFlag(priority, perms, audit); node = new MatchFlag(priority, perms, audit);
pair<iterator, bool> val = nodes.insert(make_pair(tmp, node)); 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 val.first->second;
}
return node; return node;
} }
return res->second; return res->second;