From 571ce1ba410bab8f96c073ceb7e7870e72c1b136 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 3 May 1995 02:31:31 +0000 Subject: [PATCH] Fix memory leaks in this function. The krb5_donot_replay structure was not being freed properly. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5694 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/rcache/ChangeLog | 6 ++++++ src/lib/krb5/rcache/rc_dfl.c | 33 ++++++++++++++------------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/lib/krb5/rcache/ChangeLog b/src/lib/krb5/rcache/ChangeLog index b55c33e99..30e6ffa1e 100644 --- a/src/lib/krb5/rcache/ChangeLog +++ b/src/lib/krb5/rcache/ChangeLog @@ -1,3 +1,9 @@ +Mon May 1 23:10:26 1995 Theodore Y. Ts'o (tytso@dcl) + + * rc_dfl.c (krb5_rc_dfl_recover): Fix memory leaks in this + function. The krb5_donot_replay structure was not being + freed properly. + Thu Apr 13 15:49:16 1995 Keith Vetter (keithv@fusion.com) * *.[ch]: removed unneeded INTERFACE from non-api functions. diff --git a/src/lib/krb5/rcache/rc_dfl.c b/src/lib/krb5/rcache/rc_dfl.c index 120eaa515..32999245b 100644 --- a/src/lib/krb5/rcache/rc_dfl.c +++ b/src/lib/krb5/rcache/rc_dfl.c @@ -401,21 +401,20 @@ krb5_rcache id; goto io_fail; } + if (!(rep = (krb5_donot_replay *) malloc(sizeof(krb5_donot_replay)))) { + retval = KRB5_RC_MALLOC; + goto io_fail; + } + rep->client = NULL; + rep->server = NULL; + /* now read in each auth_replay and insert into table */ for (;;) { - rep = NULL; if (krb5_rc_io_mark(context, &t->d)) { retval = KRB5_RC_IO; goto io_fail; } - if (!(rep = (krb5_donot_replay *) malloc(sizeof(krb5_donot_replay)))) { - retval = KRB5_RC_MALLOC; - goto io_fail; - } - rep->client = NULL; - rep->server = NULL; - retval = krb5_rc_io_fetch (context, t, rep, (int) max_size); if (retval == KRB5_RC_IO_EOF) @@ -424,22 +423,18 @@ krb5_rcache id; goto io_fail; - if (alive(context, rep,t->lifespan) == CMP_EXPIRED) { - krb5_rc_free_entry(context, &rep); - continue; + if (alive(context, rep,t->lifespan) != CMP_EXPIRED) { + if (store(context, id, rep) == CMP_MALLOC) { + retval = KRB5_RC_MALLOC; goto io_fail; + } } - - if (store(context, id,rep) == CMP_MALLOC) {/* can't be a replay */ - retval = KRB5_RC_MALLOC; goto io_fail; - } /* - * store() copies the server & client fields to make sure - * they don't get stomped on by other callers, so we need to - * free them + * free fields allocated by rc_io_fetch */ FREE(rep->server); FREE(rep->client); - rep = NULL; + rep->server = 0; + rep->client = 0; } retval = 0; krb5_rc_io_unmark(context, &t->d); -- 2.26.2