summaryrefslogtreecommitdiffstats
path: root/crypto/siphash
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2018-04-05 15:13:55 -0400
committerRich Salz <rsalz@openssl.org>2018-04-05 15:13:55 -0400
commit7de2b9c4afd90359e47d81a5fa70bcb8506fbf91 (patch)
tree6dd747cfc308dcae60f4aaf7e8ba354073e8413b /crypto/siphash
parent77579510aa40aa769ceafc7a0c856381800e79c2 (diff)
Set error code if alloc returns NULL
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5886)
Diffstat (limited to 'crypto/siphash')
-rw-r--r--crypto/siphash/siphash_pmeth.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/siphash/siphash_pmeth.c b/crypto/siphash/siphash_pmeth.c
index ae16e55878..a5211f2e96 100644
--- a/crypto/siphash/siphash_pmeth.c
+++ b/crypto/siphash/siphash_pmeth.c
@@ -12,6 +12,7 @@
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/evp.h>
+#include <openssl/err.h>
#include "internal/siphash.h"
#include "siphash_local.h"
#include "internal/evp_int.h"
@@ -27,9 +28,10 @@ static int pkey_siphash_init(EVP_PKEY_CTX *ctx)
{
SIPHASH_PKEY_CTX *pctx;
- pctx = OPENSSL_zalloc(sizeof(*pctx));
- if (pctx == NULL)
+ if ((pctx = OPENSSL_zalloc(sizeof(*pctx))) == NULL) {
+ CRYPTOerr(CRYPTO_F_PKEY_SIPHASH_INIT, ERR_R_MALLOC_FAILURE);
return 0;
+ }
pctx->ktmp.type = V_ASN1_OCTET_STRING;
EVP_PKEY_CTX_set_data(ctx, pctx);