From a4396ee8199772ee6fe24319b0121a3ba8e244cb Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Tue, 25 Jan 2022 15:35:51 -0600 Subject: [PATCH] krb5: Fix leak in kcm_gen_new() --- lib/krb5/kcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/krb5/kcm.c b/lib/krb5/kcm.c index f2751d0e5..a75fc03f9 100644 --- a/lib/krb5/kcm.c +++ b/lib/krb5/kcm.c @@ -353,8 +353,7 @@ kcm_free(krb5_context context, krb5_ccache *id) krb5_kcmcache *k = KCMCACHE(*id); if (k != NULL) { - if (k->name != NULL) - free(k->name); + free(k->name); memset_s(k, sizeof(*k), 0, sizeof(*k)); krb5_data_free(&(*id)->data); } @@ -446,6 +445,8 @@ kcm_gen_new(krb5_context context, const krb5_cc_ops *ops, krb5_ccache *id) return ret; } + free(k->name); + k->name = NULL; ret = krb5_ret_stringz(response, &k->name); if (ret) ret = KRB5_CC_IO;