[SSSD] [PATCH] krb5: Use right function to free data
Jakub Hrozek
jhrozek at redhat.com
Tue Oct 22 06:24:13 UTC 2013
On Mon, Oct 14, 2013 at 02:22:43PM +0200, Lukas Slebodnik wrote:
> >make sense, but please call krb5_free_cred_contents() before to make
> >sure all cred content is freed as well.
> Nice catch. I didn't realise it.
>
> >
> >bye,
> >Sumit
> >
> >> } else {
> >> *_cred = cred;
> >> }
>
> Updated patch atached.
>
> LS
> From 3b78c1eb5e5d4f680e3cef20229b0ac189471701 Mon Sep 17 00:00:00 2001
> From: Lukas Slebodnik <lslebodn at redhat.com>
> Date: Mon, 14 Oct 2013 11:08:48 +0200
> Subject: [PATCH] krb5: Use right function to free data.
>
> In function create_empty_cred, krb5_creds was aloocated using calloc,
> but krb5_free_creds was used to remove this creds in done section.
> Therefore clang static analyzer repoted this as warning:
> Potential leak of memory pointed to by 'cred'
> ---
> src/providers/krb5/krb5_child.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
> index 24a1fe1badd682bd9017ee14a5210d6dcacb8376..72a7f9c959551049d4fac48ad0c0966486e030be 100644
> --- a/src/providers/krb5/krb5_child.c
> +++ b/src/providers/krb5/krb5_child.c
> @@ -424,7 +424,8 @@ static krb5_error_code create_empty_cred(krb5_context ctx, krb5_principal princ,
>
> done:
> if (kerr != 0) {
> - krb5_free_creds(ctx, cred);
> + krb5_free_cred_contents(ctx, cred);
> + free(cred);
> } else {
> *_cred = cred;
> }
> --
> 1.8.3.1
>
Sumit's concerns were addressed and the patch builds fine.
ACK
More information about the sssd-devel
mailing list