summaryrefslogtreecommitdiffstats
path: root/crypto/cms/cms_enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/cms/cms_enc.c')
-rw-r--r--crypto/cms/cms_enc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/cms/cms_enc.c b/crypto/cms/cms_enc.c
index ed913426bc..853e2f1291 100644
--- a/crypto/cms/cms_enc.c
+++ b/crypto/cms/cms_enc.c
@@ -168,9 +168,10 @@ int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec,
{
ec->cipher = cipher;
if (key) {
- ec->key = OPENSSL_malloc(keylen);
- if (ec->key == NULL)
+ if ((ec->key = OPENSSL_malloc(keylen)) == NULL) {
+ CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT, ERR_R_MALLOC_FAILURE);
return 0;
+ }
memcpy(ec->key, key, keylen);
}
ec->keylen = keylen;