On (14/10/13 12:32), Sumit Bose wrote: >On Mon, Oct 14, 2013 at 11:16:41AM +0200, Lukas Slebodnik wrote: >> ehlo, >> >> This patch fixes warning reported by clang static analyzer. >> Simple patch is attached. >> >> LS > >> From 3c910455b63348e52026d9d61870ed44380e44e2 Mon Sep 17 00:00:00 2001 >> From: Lukas Slebodnik <lsleb...@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 | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/src/providers/krb5/krb5_child.c >> b/src/providers/krb5/krb5_child.c >> index >> 24a1fe1badd682bd9017ee14a5210d6dcacb8376..8c5940ac285109cb45eabd21f399d8df3cc93031 >> 100644 >> --- a/src/providers/krb5/krb5_child.c >> +++ b/src/providers/krb5/krb5_child.c >> @@ -424,7 +424,7 @@ static krb5_error_code create_empty_cred(krb5_context >> ctx, krb5_principal princ, >> >> done: >> if (kerr != 0) { >> - krb5_free_creds(ctx, cred); >> + free(cred); > >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 <lsleb...@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
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/sssd-devel