summaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_pmeth.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2018-04-03 17:31:16 +0200
committerRich Salz <rsalz@openssl.org>2018-04-03 17:31:16 +0200
commitcdb10bae3f773401e039c55965eb177a6f3fc160 (patch)
treec69b1b2bc385d3f600684cf8285b9ff80322c48f /crypto/ec/ec_pmeth.c
parentFix some errors in the mem leaks docs (diff)
downloadopenssl-cdb10bae3f773401e039c55965eb177a6f3fc160.tar.xz
openssl-cdb10bae3f773401e039c55965eb177a6f3fc160.zip
Set error code on alloc failures
Almost all *alloc failures now set an error code. Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/5842)
Diffstat (limited to 'crypto/ec/ec_pmeth.c')
-rw-r--r--crypto/ec/ec_pmeth.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c
index f1e519e9a0..5be292379a 100644
--- a/crypto/ec/ec_pmeth.c
+++ b/crypto/ec/ec_pmeth.c
@@ -46,9 +46,10 @@ static int pkey_ec_init(EVP_PKEY_CTX *ctx)
{
EC_PKEY_CTX *dctx;
- dctx = OPENSSL_zalloc(sizeof(*dctx));
- if (dctx == NULL)
+ if ((dctx = OPENSSL_zalloc(sizeof(*dctx))) == NULL) {
+ ECerr(EC_F_PKEY_EC_INIT, ERR_R_MALLOC_FAILURE);
return 0;
+ }
dctx->cofactor_mode = -1;
dctx->kdf_type = EVP_PKEY_ECDH_KDF_NONE;
@@ -297,9 +298,10 @@ static int pkey_ec_kdf_derive(EVP_PKEY_CTX *ctx,
return 0;
if (!pkey_ec_derive(ctx, NULL, &ktmplen))
return 0;
- ktmp = OPENSSL_malloc(ktmplen);
- if (ktmp == NULL)
+ if ((ktmp = OPENSSL_malloc(ktmplen)) == NULL) {
+ ECerr(EC_F_PKEY_EC_KDF_DERIVE, ERR_R_MALLOC_FAILURE);
return 0;
+ }
if (!pkey_ec_derive(ctx, ktmp, &ktmplen))
goto err;
/* Do KDF stuff */