Check for malloc failure
authorRich Salz <rsalz@openssl.org>
Mon, 27 Nov 2017 19:11:36 +0000 (14:11 -0500)
committerRich Salz <rsalz@openssl.org>
Mon, 27 Nov 2017 19:59:13 +0000 (14:59 -0500)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4805)

(cherry picked from commit 378db52bb0177ae03cac3c3ba194bb6dec34a2d7)

crypto/cms/cms_sd.c

index 76c1f53b564df7942fea600f5b0bc88ce47e7cea..4108fe70827694dddbb78ffe17839f5daef85d67 100644 (file)
@@ -713,8 +713,10 @@ int CMS_SignerInfo_verify(CMS_SignerInfo *si)
     md = EVP_get_digestbyobj(si->digestAlgorithm->algorithm);
     if (md == NULL)
         return -1;
-    if (si->mctx == NULL)
-        si->mctx = EVP_MD_CTX_new();
+    if (si->mctx == NULL && (si->mctx = EVP_MD_CTX_new()) == NULL) {
+        CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY, ERR_R_MALLOC_FAILURE);
+        return -1;
+    }
     mctx = si->mctx;
     if (EVP_DigestVerifyInit(mctx, &si->pctx, md, NULL, si->pkey) <= 0)
         goto err;