From: Theodore Tso Date: Wed, 1 Dec 1993 22:00:04 +0000 (+0000) Subject: Fix memory leak; make sure cur_entry is freed, as well as its contents X-Git-Tag: krb5-1.0-beta3~124 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=875c1214865914b338392b9da1890567d2bdff18;p=krb5.git Fix memory leak; make sure cur_entry is freed, as well as its contents git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3054 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/keytab/file/ktf_get_en.c b/src/lib/krb5/keytab/file/ktf_get_en.c index f46b9a826..ff0ce22c5 100644 --- a/src/lib/krb5/keytab/file/ktf_get_en.c +++ b/src/lib/krb5/keytab/file/ktf_get_en.c @@ -69,18 +69,20 @@ OLDDECLARG(krb5_keytab_entry *, entry) break; } krb5_kt_free_entry(cur_entry); + krb5_xfree(cur_entry); } if (kerror && kerror != KRB5_KT_END) { (void) krb5_ktfileint_close(id); return kerror; } - if (!(kerror = krb5_ktfileint_close(id))) { - if (cur_entry) { - *entry = *cur_entry; - krb5_xfree(cur_entry); - } else - kerror = KRB5_KT_NOTFOUND; - } else + if ((kerror = krb5_ktfileint_close(id)) != 0) { krb5_kt_free_entry(cur_entry); - return kerror; + krb5_xfree(cur_entry); + return kerror; + } + if (!cur_entry) + return KRB5_KT_NOTFOUND; + *entry = *cur_entry; + krb5_xfree(cur_entry); + return 0; }