From 2f8402b36e9f685d84d92aff64d3070abe98a24c Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Thu, 20 Feb 1997 06:15:20 +0000 Subject: [PATCH] Removed unneeded call to krb5_init_ets Check the return value of krb5_init_context. Re-arranged some of the code so that all resources are freed if there is an error. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9924 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/v5passwdd/kpasswd.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/kadmin/v5passwdd/kpasswd.c b/src/kadmin/v5passwdd/kpasswd.c index 0254b5207..327c081a3 100644 --- a/src/kadmin/v5passwdd/kpasswd.c +++ b/src/kadmin/v5passwdd/kpasswd.c @@ -241,25 +241,30 @@ main(argc, argv) return(error); } + /* + * Initialize Kerberos + */ + kret = krb5_init_context(&kcontext); + if (kret) { + com_err(argv[0], kret, "while initializing krb5"); + exit(1); + } + /* Get space for passwords */ if ( ((npassword = (char *) malloc(KRB5_ADM_MAX_PASSWORD_LEN)) == (char *) NULL) || ((opassword = (char *) malloc(KRB5_ADM_MAX_PASSWORD_LEN)) - == (char *) NULL)) { + == (char *) NULL)) + { fprintf(stderr, kpwd_no_memory_fmt, argv[0], KRB5_ADM_MAX_PASSWORD_LEN, kpwd_password_text); if (npassword) free(npassword); + krb5_free_context(kcontext); return(ENOMEM); } - /* - * Initialize Kerberos - */ - krb5_init_context(&kcontext); - krb5_init_ets(kcontext); - /* From now on, all error legs via 'goto cleanup' */ if (name) { -- 2.26.2