[apparmor] [patch 09/18] parser: fix memory leak on calloc() failure

Steve Beattie steve at nxnw.org
Thu Jan 16 22:06:17 UTC 2014


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

Signed-off-by: Steve Beattie <steve at nxnw.org>
---
 parser/parser_alias.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: b/parser/parser_alias.c
===================================================================
--- a/parser/parser_alias.c
+++ b/parser/parser_alias.c
@@ -177,8 +177,10 @@ static void process_name(const void *nod
 			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;




More information about the AppArmor mailing list