[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apparmor-dev
Subject:    Re: [apparmor] [patch 09/18] parser: fix memory leak on calloc() failure
From:       John Johansen <john.johansen () canonical ! com>
Date:       2014-01-24 10:45:53
Message-ID: 52E24461.9070002 () canonical ! com
[Download RAW message or body]

On 01/16/2014 02:06 PM, Steve Beattie wrote:
> 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>

> ---
> 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;
> 
> 
> -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe \
> at: https://lists.ubuntu.com/mailman/listinfo/apparmor 


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic