Only release keys if they are allocated

This commit is contained in:
Love Hornquist Astrand
2009-08-25 23:54:58 -07:00
parent 03998aeccb
commit 23aebd619b

View File

@@ -2203,13 +2203,15 @@ _krb5_get_init_creds_opt_free_pkinit(krb5_get_init_creds_opt *opt)
ctx = opt->opt_private->pk_init_ctx;
switch (ctx->keyex) {
case USE_DH:
DH_free(ctx->u.dh);
if (ctx->u.dh)
DH_free(ctx->u.dh);
break;
case USE_RSA:
break;
case USE_ECDH:
#ifdef HAVE_OPENSSL
EC_KEY_free(ctx->u.eckey);
if (ctx->u.eckey)
EC_KEY_free(ctx->u.eckey);
#endif
break;
}