Don't leak EVP_MD_CTX on error path
authorMatt Caswell <matt@openssl.org>
Wed, 27 Apr 2016 12:22:29 +0000 (13:22 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 28 Apr 2016 12:13:09 +0000 (13:13 +0100)
The cms_SignerInfo_content_sign() function allocated an EVP_MD_CTX but
then failed to free it on an error path.

Reviewed-by: Richard Levitte <levitte@openssl.org>
crypto/cms/cms_sd.c

index 151f40f9a54f07c261cd27e52ef1ba653a4a04f3..e4739b39d9e1a219cb61248e417ed12c621b6c08 100644 (file)
@@ -588,7 +588,7 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms,
 
     if (!si->pkey) {
         CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, CMS_R_NO_PRIVATE_KEY);
-        return 0;
+        goto err;
     }
 
     if (!cms_DigestAlgorithm_find_ctx(mctx, chain, si->digestAlgorithm))