krb5 commit: Clean up context after failed open in libkdb5

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/849b7056e703bd3724d909263769ce190db59acc
commit 849b7056e703bd3724d909263769ce190db59acc
Author: Greg Hudson <[email protected]>
Date:   Wed Jun 23 16:57:39 2021 -0400

    Clean up context after failed open in libkdb5
    
    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.

 src/lib/kdb/kdb5.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c
index 47e9b31..11e2430 100644
--- a/src/lib/kdb/kdb5.c
+++ b/src/lib/kdb/kdb5.c
@@ -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;
 }
 
@@ -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;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.