summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/evp/exchange.c1
-rw-r--r--crypto/evp/pmeth_fn.c9
-rw-r--r--crypto/evp/pmeth_gn.c4
-rw-r--r--crypto/evp/signature.c1
4 files changed, 9 insertions, 6 deletions
diff --git a/crypto/evp/exchange.c b/crypto/evp/exchange.c
index 6423fd9eff..26d7e1ce95 100644
--- a/crypto/evp/exchange.c
+++ b/crypto/evp/exchange.c
@@ -264,6 +264,7 @@ int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
return ret ? 1 : 0;
err:
+ evp_pkey_ctx_free_old_ops(ctx);
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return 0;
diff --git a/crypto/evp/pmeth_fn.c b/crypto/evp/pmeth_fn.c
index 4d8d3e91b1..8bc59c40b9 100644
--- a/crypto/evp/pmeth_fn.c
+++ b/crypto/evp/pmeth_fn.c
@@ -126,11 +126,8 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation)
goto err;
}
- if (ret <= 0) {
- cipher->freectx(ctx->op.ciph.ciphprovctx);
- ctx->op.ciph.ciphprovctx = NULL;
+ if (ret <= 0)
goto err;
- }
return 1;
legacy:
@@ -162,8 +159,10 @@ static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation)
}
err:
- if (ret <= 0)
+ if (ret <= 0) {
+ evp_pkey_ctx_free_old_ops(ctx);
ctx->operation = EVP_PKEY_OP_UNDEFINED;
+ }
return ret;
}
diff --git a/crypto/evp/pmeth_gn.c b/crypto/evp/pmeth_gn.c
index a775d2bee7..fb861d2487 100644
--- a/crypto/evp/pmeth_gn.c
+++ b/crypto/evp/pmeth_gn.c
@@ -93,8 +93,10 @@ static int gen_init(EVP_PKEY_CTX *ctx, int operation)
#endif
end:
- if (ret <= 0 && ctx != NULL)
+ if (ret <= 0 && ctx != NULL) {
+ evp_pkey_ctx_free_old_ops(ctx);
ctx->operation = EVP_PKEY_OP_UNDEFINED;
+ }
return ret;
not_supported:
diff --git a/crypto/evp/signature.c b/crypto/evp/signature.c
index d845ac12db..b7a7f79606 100644
--- a/crypto/evp/signature.c
+++ b/crypto/evp/signature.c
@@ -503,6 +503,7 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, int operation)
return ret;
err:
+ evp_pkey_ctx_free_old_ops(ctx);
ctx->operation = EVP_PKEY_OP_UNDEFINED;
return ret;
}