summaryrefslogtreecommitdiffstats
path: root/crypto/hmac
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2018-04-05 21:13:55 +0200
committerRich Salz <rsalz@openssl.org>2018-04-05 21:13:55 +0200
commit7de2b9c4afd90359e47d81a5fa70bcb8506fbf91 (patch)
tree6dd747cfc308dcae60f4aaf7e8ba354073e8413b /crypto/hmac
parentUpdate the genpkey documentation (diff)
downloadopenssl-7de2b9c4afd90359e47d81a5fa70bcb8506fbf91.tar.xz
openssl-7de2b9c4afd90359e47d81a5fa70bcb8506fbf91.zip
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/hmac')
-rw-r--r--crypto/hmac/hm_pmeth.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/hmac/hm_pmeth.c b/crypto/hmac/hm_pmeth.c
index 5b98477f9c..ceca6f7183 100644
--- a/crypto/hmac/hm_pmeth.c
+++ b/crypto/hmac/hm_pmeth.c
@@ -13,6 +13,7 @@
#include <openssl/x509v3.h>
#include <openssl/evp.h>
#include <openssl/hmac.h>
+#include <openssl/err.h>
#include "internal/evp_int.h"
/* HMAC pkey context structure */
@@ -27,9 +28,10 @@ static int pkey_hmac_init(EVP_PKEY_CTX *ctx)
{
HMAC_PKEY_CTX *hctx;
- hctx = OPENSSL_zalloc(sizeof(*hctx));
- if (hctx == NULL)
+ if ((hctx = OPENSSL_zalloc(sizeof(*hctx))) == NULL) {
+ CRYPTOerr(CRYPTO_F_PKEY_HMAC_INIT, ERR_R_MALLOC_FAILURE);
return 0;
+ }
hctx->ktmp.type = V_ASN1_OCTET_STRING;
hctx->ctx = HMAC_CTX_new();
if (hctx->ctx == NULL) {