diff options
author | Rich Salz <rsalz@openssl.org> | 2018-04-05 15:13:55 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2018-04-05 15:13:55 -0400 |
commit | 7de2b9c4afd90359e47d81a5fa70bcb8506fbf91 (patch) | |
tree | 6dd747cfc308dcae60f4aaf7e8ba354073e8413b /crypto/cmac/cmac.c | |
parent | 77579510aa40aa769ceafc7a0c856381800e79c2 (diff) | |
download | openssl-7de2b9c4afd90359e47d81a5fa70bcb8506fbf91.zip openssl-7de2b9c4afd90359e47d81a5fa70bcb8506fbf91.tar.gz openssl-7de2b9c4afd90359e47d81a5fa70bcb8506fbf91.tar.bz2 |
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/cmac/cmac.c')
-rw-r--r-- | crypto/cmac/cmac.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/cmac/cmac.c b/crypto/cmac/cmac.c index 46e3cb7..0c59659 100644 --- a/crypto/cmac/cmac.c +++ b/crypto/cmac/cmac.c @@ -12,6 +12,7 @@ #include <string.h> #include "internal/cryptlib.h" #include <openssl/cmac.h> +#include <openssl/err.h> struct CMAC_CTX_st { /* Cipher context to use */ @@ -46,9 +47,10 @@ CMAC_CTX *CMAC_CTX_new(void) { CMAC_CTX *ctx; - ctx = OPENSSL_malloc(sizeof(*ctx)); - if (ctx == NULL) + if ((ctx = OPENSSL_malloc(sizeof(*ctx))) == NULL) { + CRYPTOerr(CRYPTO_F_CMAC_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; + } ctx->cctx = EVP_CIPHER_CTX_new(); if (ctx->cctx == NULL) { OPENSSL_free(ctx); |