From 875c1214865914b338392b9da1890567d2bdff18 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 1 Dec 1993 22:00:04 +0000 Subject: [PATCH] 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 --- src/lib/krb5/keytab/file/ktf_get_en.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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; } -- 2.26.2