In kg_new_connection(), make sure k_cred is freed in all failure
authorGreg Hudson <ghudson@mit.edu>
Thu, 22 Apr 2010 20:07:08 +0000 (20:07 +0000)
committerGreg Hudson <ghudson@mit.edu>
Thu, 22 Apr 2010 20:07:08 +0000 (20:07 +0000)
cases.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23926 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/gssapi/krb5/init_sec_context.c

index 82baca128a3a43346715cba9628fd566d3034323..b81d5b31284ee2c19dc6ed4d30b510f4a41743dd 100644 (file)
@@ -483,7 +483,7 @@ kg_new_connection(
 {
     OM_uint32 major_status;
     krb5_error_code code;
-    krb5_creds *k_cred;
+    krb5_creds *k_cred = NULL;
     krb5_gss_ctx_id_rec *ctx, *ctx_free;
     krb5_timestamp now;
     gss_buffer_desc token;
@@ -618,8 +618,6 @@ kg_new_connection(
             goto fail;
     }
 
-    krb5_free_creds(context, k_cred);
-    k_cred = NULL;
     ctx->enc = NULL;
     ctx->seq = NULL;
     ctx->have_acceptor_subkey = 0;
@@ -672,6 +670,7 @@ kg_new_connection(
     }
 
 fail:
+    krb5_free_creds(context, k_cred);
     if (ctx_free) {
         if (ctx_free->auth_context)
             krb5_auth_con_free(context, ctx_free->auth_context);