Skip to content

Commit

Permalink
Avoid freeing context on error
Browse files Browse the repository at this point in the history
Freeing the allocated KDF context seems wrong when derive errors.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from #20528)
  • Loading branch information
paulidale committed Mar 20, 2023
1 parent 7c45b7c commit 6ec3d31
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions providers/implementations/kdfs/argon2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,6 @@ static int kdf_argon2_derive(void *vctx, unsigned char *out, size_t outlen,

ctx->mac = EVP_MAC_fetch(ctx->libctx, "blake2bmac", ctx->propq);
if (ctx->mac == NULL) {
OPENSSL_free(ctx);
ERR_raise_data(ERR_LIB_PROV, PROV_R_MISSING_MAC,
"cannot fetch blake2bmac");
return 0;
Expand All @@ -1034,7 +1033,6 @@ static int kdf_argon2_derive(void *vctx, unsigned char *out, size_t outlen,
ctx->md = EVP_MD_fetch(ctx->libctx, "blake2b512", ctx->propq);
if (ctx->md == NULL) {
EVP_MAC_free(ctx->mac);
OPENSSL_free(ctx);
ERR_raise_data(ERR_LIB_PROV, PROV_R_MISSING_MESSAGE_DIGEST,
"canot fetch blake2b512");
return 0;
Expand Down

0 comments on commit 6ec3d31

Please sign in to comment.