Fix memory leak; make sure cur_entry is freed, as well as its contents
authorTheodore Tso <tytso@mit.edu>
Wed, 1 Dec 1993 22:00:04 +0000 (22:00 +0000)
committerTheodore Tso <tytso@mit.edu>
Wed, 1 Dec 1993 22:00:04 +0000 (22:00 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3054 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/keytab/file/ktf_get_en.c

index f46b9a826100f44a73c5765312d8c0fba552f5e6..ff0ce22c5d04836df7067408758ac019945929c8 100644 (file)
@@ -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;
 }