svn rev #21890: trunk/src/lib/krb5/keytab/
ghudson@MIT.EDU
ghudson at MIT.EDU
Thu Feb 5 13:19:27 EST 2009
http://src.mit.edu/fisheye/changelog/krb5/?cs=21890
Commit By: ghudson
Log Message:
ticket: 6367
tags: pullup
target_version: 1.7
Fix a memory leak in krb5_kt_resolve when we fail to lock
kt_typehead_lock.
Changed Files:
U trunk/src/lib/krb5/keytab/ktbase.c
Modified: trunk/src/lib/krb5/keytab/ktbase.c
===================================================================
--- trunk/src/lib/krb5/keytab/ktbase.c 2009-02-05 02:59:08 UTC (rev 21889)
+++ trunk/src/lib/krb5/keytab/ktbase.c 2009-02-05 18:19:23 UTC (rev 21890)
@@ -162,10 +162,10 @@
krb5_kt_resolve (krb5_context context, const char *name, krb5_keytab *ktid)
{
const struct krb5_kt_typelist *tlist;
- char *pfx;
+ char *pfx = NULL;
unsigned int pfxlen;
const char *cp, *resid;
- krb5_error_code err;
+ krb5_error_code err = 0;
cp = strchr (name, ':');
if (!cp) {
@@ -201,7 +201,7 @@
err = k5_mutex_lock(&kt_typehead_lock);
if (err)
- return err;
+ goto cleanup;
tlist = kt_typehead;
/* Don't need to hold the lock, since entries are never modified
or removed once they're in the list. Just need to protect
@@ -209,12 +209,15 @@
k5_mutex_unlock(&kt_typehead_lock);
for (; tlist; tlist = tlist->next) {
if (strcmp (tlist->ops->prefix, pfx) == 0) {
- free(pfx);
- return (*tlist->ops->resolve)(context, resid, ktid);
+ err = (*tlist->ops->resolve)(context, resid, ktid);
+ goto cleanup;
}
}
+ err = KRB5_KT_UNKNOWN_TYPE;
+
+cleanup:
free(pfx);
- return KRB5_KT_UNKNOWN_TYPE;
+ return err;
}
/*
More information about the cvs-krb5
mailing list