From: Tom Yu Date: Fri, 7 Mar 2008 20:43:42 +0000 (+0000) Subject: pull up r20254 from trunk X-Git-Tag: krb5-1.6.4-beta1~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5981a284e913716827f5c1174ca041aec647a5b6;p=krb5.git pull up r20254 from trunk r20254@cathode-dark-space: jander | 2008-03-04 15:27:19 -0500 ticket: 5897 tags: pullup Fix memory leak by delaying instantiation of lid until it's needed. ticket: 5897 version_fixed: 1.6.4 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@20258 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/ccache/cc_memory.c b/src/lib/krb5/ccache/cc_memory.c index 124548ce6..a289425e1 100644 --- a/src/lib/krb5/ccache/cc_memory.c +++ b/src/lib/krb5/ccache/cc_memory.c @@ -244,12 +244,6 @@ krb5_mcc_resolve (krb5_context context, krb5_ccache *id, const char *residual) krb5_error_code err; krb5_mcc_data *d; - lid = (krb5_ccache) malloc(sizeof(struct _krb5_ccache)); - if (lid == NULL) - return KRB5_CC_NOMEM; - - lid->ops = &krb5_mcc_ops; - err = k5_mutex_lock(&krb5int_mcc_mutex); if (err) return err; @@ -262,11 +256,16 @@ krb5_mcc_resolve (krb5_context context, krb5_ccache *id, const char *residual) err = new_mcc_data(residual, &d); if (err) { k5_mutex_unlock(&krb5int_mcc_mutex); - krb5_xfree(lid); return err; } } k5_mutex_unlock(&krb5int_mcc_mutex); + + lid = (krb5_ccache) malloc(sizeof(struct _krb5_ccache)); + if (lid == NULL) + return KRB5_CC_NOMEM; + + lid->ops = &krb5_mcc_ops; lid->data = d; *id = lid; return KRB5_OK;