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

List:       netcf-devel
Subject:    [netcf-devel] [PATCH] ncftool: avoid memory leak
From:       laine () laine ! org (Laine Stump)
Date:       2011-09-27 17:37:12
Message-ID: 4E8209C8.2020007 () laine ! org
[Download RAW message or body]

On 09/27/2011 02:25 AM, ajia at redhat.com wrote:
> From: Alex Jia<ajia at redhat.com>
>
> * src/ncftool.c: Calling allocation function 'ncf_lookup_by_name' to allocate
>    memory to 'nif', however, it hasn't been released before return.
>
> Signed-off-by: Alex Jia<ajia at redhat.com>
> ---
>   src/ncftool.c |    4 +++-
>   1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/src/ncftool.c b/src/ncftool.c
> index c9e26a2..90c6cbf 100644
> --- a/src/ncftool.c
> +++ b/src/ncftool.c
> @@ -390,8 +390,10 @@ static int cmd_undefine(const struct command *cmd) {
>           return CMD_RES_ERR;
>
>       r = ncf_if_undefine(nif);
> -    if (r<  0)
> +    if (r<  0) {
> +        ncf_if_free(nif);
>           return CMD_RES_ERR;
> +    }
>
>       printf("%s undefined\n", name);
>       ncf_if_free(nif);

ACK and pushed. Thanks for noticing that in the coverity output!


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

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