2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-30 22:05:27 +00:00

parser: fix memory leak on calloc() failure

Fix leaked memory if calloc() fails. Found by cppcheck.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
Steve Beattie
2014-01-24 10:58:06 -08:00
parent 8237c6fb28
commit fb3baeaf23

View File

@@ -177,8 +177,10 @@ static void process_name(const void *nodep, VISIT value, int __unused level)
return;
/* aliases create alternate names */
alt = (struct alt_name *) calloc(1, sizeof(struct alt_name));
if (!alt)
if (!alt) {
free(n);
return;
}
alt->name = n;
alt->next = prof->altnames;
prof->altnames = alt;