Removed unneeded call to krb5_init_ets
authorRichard Basch <probe@mit.edu>
Thu, 20 Feb 1997 06:15:20 +0000 (06:15 +0000)
committerRichard Basch <probe@mit.edu>
Thu, 20 Feb 1997 06:15:20 +0000 (06:15 +0000)
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

index 0254b520758d0872b401d2032f9a25dd1e47e0ab..327c081a34a72e39a7e05d1768c0c9f38396a98c 100644 (file)
@@ -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) {