From 3065730b8a4cad020ed8c5d64ed41bf50b354cf5 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 16 Jan 2022 21:03:00 -0500 Subject: [PATCH] lib/kadm5: find_db_spec do not leak 'info' If a memory allocation failure occurs 'info' is leaked. Change-Id: Ie9cfff3f7d63a1af8e053d47d5ff66411916a795 --- lib/kadm5/context_s.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/kadm5/context_s.c b/lib/kadm5/context_s.c index b5674f19a..0c154ecfe 100644 --- a/lib/kadm5/context_s.c +++ b/lib/kadm5/context_s.c @@ -161,29 +161,37 @@ find_db_spec(kadm5_server_context *ctx) p = hdb_dbinfo_get_dbname(context, d); if (p) { ctx->config.dbname = strdup(p); - if (ctx->config.dbname == NULL) + if (ctx->config.dbname == NULL) { + hdb_free_dbinfo(context, &info); return krb5_enomem(context); + } } p = hdb_dbinfo_get_acl_file(context, d); if (p) { ctx->config.acl_file = strdup(p); - if (ctx->config.acl_file == NULL) + if (ctx->config.acl_file == NULL) { + hdb_free_dbinfo(context, &info); return krb5_enomem(context); + } } p = hdb_dbinfo_get_mkey_file(context, d); if (p) { ctx->config.stash_file = strdup(p); - if (ctx->config.stash_file == NULL) + if (ctx->config.stash_file == NULL) { + hdb_free_dbinfo(context, &info); return krb5_enomem(context); + } } p = hdb_dbinfo_get_log_file(context, d); if (p) { ctx->log_context.log_file = strdup(p); - if (ctx->log_context.log_file == NULL) + if (ctx->log_context.log_file == NULL) { + hdb_free_dbinfo(context, &info); return krb5_enomem(context); + } } break; }