Skip to content

Commit

Permalink
Clean up context after failed open in libkdb5
Browse files Browse the repository at this point in the history
If krb5_db_open() or krb5_db_create() fails, release the dal_handle,
as the caller is unlikely to call krb5_db_close() after a failure.
  • Loading branch information
greghudson committed Jun 28, 2021
1 parent 552d7b7 commit 849b705
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/kdb/kdb5.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ krb5_db_open(krb5_context kcontext, char **db_args, int mode)
return status;
status = v->init_module(kcontext, section, db_args, mode);
free(section);
if (status)
(void)krb5_db_fini(kcontext);
return status;
}

Expand Down Expand Up @@ -702,6 +704,8 @@ krb5_db_create(krb5_context kcontext, char **db_args)
return status;
status = v->create(kcontext, section, db_args);
free(section);
if (status)
(void)krb5_db_fini(kcontext);
return status;
}

Expand Down

0 comments on commit 849b705

Please sign in to comment.