summaryrefslogtreecommitdiffstats
path: root/crypto/evp/pmeth_gn.c
diff options
context:
space:
mode:
authorEmilia Kasper <emilia@openssl.org>2015-09-01 16:31:55 +0200
committerEmilia Kasper <emilia@openssl.org>2015-09-10 17:21:23 +0200
commite34c66c6b07d69ec4df8e488976e28d851ad87e6 (patch)
tree34cb0273ddc02f0d2a30c045d4b2dd429b7cdd67 /crypto/evp/pmeth_gn.c
parentcdde7b49a4ded6ce25b348314a231b99ce884c06 (diff)
RT3754: check for NULL pointer
Fix both the caller to error out on malloc failure, as well as the eventual callee to handle a NULL gracefully. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Diffstat (limited to 'crypto/evp/pmeth_gn.c')
-rw-r--r--crypto/evp/pmeth_gn.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/crypto/evp/pmeth_gn.c b/crypto/evp/pmeth_gn.c
index 705801fc02..9416e1ab72 100644
--- a/crypto/evp/pmeth_gn.c
+++ b/crypto/evp/pmeth_gn.c
@@ -96,12 +96,17 @@ int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
return -1;
}
- if (!ppkey)
+ if (ppkey == NULL)
return -1;
- if (!*ppkey)
+ if (*ppkey == NULL)
*ppkey = EVP_PKEY_new();
+ if (*ppkey == NULL) {
+ EVPerr(EVP_F_EVP_PKEY_PARAMGEN, ERR_R_MALLOC_FAILURE);
+ return -1;
+ }
+
ret = ctx->pmeth->paramgen(ctx, *ppkey);
if (ret <= 0) {
EVP_PKEY_free(*ppkey);