crypto/cms/cms_sd.c:890: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 821, column 24 is not reachable after line 890, column 5.
Showing all 90 steps of the trace


crypto/cms/cms_sd.c:818:1: start of procedure CMS_SignerInfo_verify_content()
816.   }
817.   
818. > int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain)
819.   {
820.       ASN1_OCTET_STRING *os = NULL;

crypto/cms/cms_sd.c:820:5: 
818.   int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain)
819.   {
820. >     ASN1_OCTET_STRING *os = NULL;
821.       EVP_MD_CTX *mctx = EVP_MD_CTX_new();
822.       EVP_PKEY_CTX *pkctx = NULL;

crypto/cms/cms_sd.c:821:5: 
819.   {
820.       ASN1_OCTET_STRING *os = NULL;
821. >     EVP_MD_CTX *mctx = EVP_MD_CTX_new();
822.       EVP_PKEY_CTX *pkctx = NULL;
823.       int r = -1;

crypto/evp/digest.c:152:1: start of procedure EVP_MD_CTX_new()
  150.   }
  151.   
  152. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  153.   {
  154.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:154:5: 
  152.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  153.   {
  154. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  155.   }
  156.   

crypto/mem.c:158:1: start of procedure CRYPTO_zalloc()
    156.   }
    157.   
    158. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    159.   {
    160.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:160:5: 
    158.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    159.   {
    160. >     void *ret = CRYPTO_malloc(num, file, line);
    161.   
    162.       if (ret != NULL)

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
      117.   }
      118.   
      119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121.       void *ret = NULL;

crypto/mem.c:121:5: 
      119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121. >     void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
      121.       void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      124.           return malloc_impl(num, file, line);
      125.   

crypto/mem.c:126:9: Taking false branch
      124.           return malloc_impl(num, file, line);
      125.   
      126.       if (num <= 0)
                     ^
      127.           return NULL;
      128.   

crypto/mem.c:129:5: 
      127.           return NULL;
      128.   
      129. >     allow_customize = 0;
      130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:139:24: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:140:5: 
      138.   #else
      139.       osslargused(file); osslargused(line);
      140. >     ret = malloc(num);
      141.   #endif
      142.   

crypto/mem.c:155:5: 
      153.   #endif
      154.   
      155. >     return ret;
      156.   }
      157.   

crypto/mem.c:156:1: return from a call to CRYPTO_malloc
      154.   
      155.       return ret;
      156. > }
      157.   
      158.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:162:9: Taking true branch
    160.       void *ret = CRYPTO_malloc(num, file, line);
    161.   
    162.       if (ret != NULL)
                   ^
    163.           memset(ret, 0, num);
    164.       return ret;

crypto/mem.c:163:9: 
    161.   
    162.       if (ret != NULL)
    163. >         memset(ret, 0, num);
    164.       return ret;
    165.   }

crypto/mem.c:164:5: 
    162.       if (ret != NULL)
    163.           memset(ret, 0, num);
    164. >     return ret;
    165.   }
    166.   

crypto/mem.c:165:1: return from a call to CRYPTO_zalloc
    163.           memset(ret, 0, num);
    164.       return ret;
    165. > }
    166.   
    167.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:155:1: return from a call to EVP_MD_CTX_new
  153.   {
  154.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  155. > }
  156.   
  157.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/cms/cms_sd.c:822:5: 
820.       ASN1_OCTET_STRING *os = NULL;
821.       EVP_MD_CTX *mctx = EVP_MD_CTX_new();
822. >     EVP_PKEY_CTX *pkctx = NULL;
823.       int r = -1;
824.       unsigned char mval[EVP_MAX_MD_SIZE];

crypto/cms/cms_sd.c:823:5: 
821.       EVP_MD_CTX *mctx = EVP_MD_CTX_new();
822.       EVP_PKEY_CTX *pkctx = NULL;
823. >     int r = -1;
824.       unsigned char mval[EVP_MAX_MD_SIZE];
825.       unsigned int mlen;

crypto/cms/cms_sd.c:827:9: Taking false branch
825.       unsigned int mlen;
826.   
827.       if (mctx == NULL) {
               ^
828.           CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT, ERR_R_MALLOC_FAILURE);
829.           goto err;

crypto/cms/cms_sd.c:832:9: 
830.       }
831.       /* If we have any signed attributes look for messageDigest value */
832. >     if (CMS_signed_get_attr_count(si) >= 0) {
833.           os = CMS_signed_get0_data_by_OBJ(si,
834.                                            OBJ_nid2obj(NID_pkcs9_messageDigest),

crypto/cms/cms_att.c:63:1: start of procedure CMS_signed_get_attr_count()
  61.   /* CMS SignedData Attribute utilities */
  62.   
  63. > int CMS_signed_get_attr_count(const CMS_SignerInfo *si)
  64.   {
  65.       return X509at_get_attr_count(si->signedAttrs);

crypto/cms/cms_att.c:65:5: 
  63.   int CMS_signed_get_attr_count(const CMS_SignerInfo *si)
  64.   {
  65. >     return X509at_get_attr_count(si->signedAttrs);
  66.   }
  67.   

crypto/x509/x509_att.c:68:1: start of procedure X509at_get_attr_count()
    66.   #include "x509_lcl.h"
    67.   
    68. > int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x)
    69.   {
    70.       return sk_X509_ATTRIBUTE_num(x);

crypto/x509/x509_att.c:70:5: 
    68.   int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x)
    69.   {
    70. >     return sk_X509_ATTRIBUTE_num(x);
    71.   }
    72.   

include/openssl/x509.h:159:1: start of procedure sk_X509_ATTRIBUTE_num()
      157.   typedef struct x509_attributes_st X509_ATTRIBUTE;
      158.   
      159. > DEFINE_STACK_OF(X509_ATTRIBUTE)
      160.   
      161.   typedef struct X509_req_info_st X509_REQ_INFO;

crypto/stack/stack.c:316:1: start of procedure sk_num()
        314.   }
        315.   
        316. > int sk_num(const _STACK *st)
        317.   {
        318.       if (st == NULL)

crypto/stack/stack.c:318:9: Taking true branch
        316.   int sk_num(const _STACK *st)
        317.   {
        318.       if (st == NULL)
                       ^
        319.           return -1;
        320.       return st->num;

crypto/stack/stack.c:319:9: 
        317.   {
        318.       if (st == NULL)
        319. >         return -1;
        320.       return st->num;
        321.   }

crypto/stack/stack.c:321:1: return from a call to sk_num
        319.           return -1;
        320.       return st->num;
        321. > }
        322.   
        323.   void *sk_value(const _STACK *st, int i)

include/openssl/x509.h:159:1: return from a call to sk_X509_ATTRIBUTE_num
      157.   typedef struct x509_attributes_st X509_ATTRIBUTE;
      158.   
      159. > DEFINE_STACK_OF(X509_ATTRIBUTE)
      160.   
      161.   typedef struct X509_req_info_st X509_REQ_INFO;

crypto/x509/x509_att.c:71:1: return from a call to X509at_get_attr_count
    69.   {
    70.       return sk_X509_ATTRIBUTE_num(x);
    71. > }
    72.   
    73.   int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,

crypto/cms/cms_att.c:66:1: return from a call to CMS_signed_get_attr_count
  64.   {
  65.       return X509at_get_attr_count(si->signedAttrs);
  66. > }
  67.   
  68.   int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, int lastpos)

crypto/cms/cms_sd.c:832:9: Taking false branch
830.       }
831.       /* If we have any signed attributes look for messageDigest value */
832.       if (CMS_signed_get_attr_count(si) >= 0) {
               ^
833.           os = CMS_signed_get0_data_by_OBJ(si,
834.                                            OBJ_nid2obj(NID_pkcs9_messageDigest),

crypto/cms/cms_sd.c:843:10: 
841.       }
842.   
843. >     if (!cms_DigestAlgorithm_find_ctx(mctx, chain, si->digestAlgorithm))
844.           goto err;
845.   

crypto/cms/cms_lib.c:355:1: start of procedure cms_DigestAlgorithm_find_ctx()
  353.   /* Locate a message digest content from a BIO chain based on SignerInfo */
  354.   
  355. > int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
  356.                                    X509_ALGOR *mdalg)
  357.   {

crypto/cms/cms_lib.c:360:5: 
  358.       int nid;
  359.       ASN1_OBJECT *mdoid;
  360. >     X509_ALGOR_get0(&mdoid, NULL, NULL, mdalg);
  361.       nid = OBJ_obj2nid(mdoid);
  362.       /* Look for digest type to match signature */

crypto/asn1/x_algor.c:102:1: start of procedure X509_ALGOR_get0()
    100.   }
    101.   
    102. > void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
    103.                        X509_ALGOR *algor)
    104.   {

crypto/asn1/x_algor.c:105:9: Taking true branch
    103.                        X509_ALGOR *algor)
    104.   {
    105.       if (paobj)
                   ^
    106.           *paobj = algor->algorithm;
    107.       if (pptype) {

crypto/asn1/x_algor.c:106:9: 
    104.   {
    105.       if (paobj)
    106. >         *paobj = algor->algorithm;
    107.       if (pptype) {
    108.           if (algor->parameter == NULL) {

crypto/asn1/x_algor.c:107:9: Taking false branch
    105.       if (paobj)
    106.           *paobj = algor->algorithm;
    107.       if (pptype) {
                   ^
    108.           if (algor->parameter == NULL) {
    109.               *pptype = V_ASN1_UNDEF;

crypto/asn1/x_algor.c:107:5: 
    105.       if (paobj)
    106.           *paobj = algor->algorithm;
    107. >     if (pptype) {
    108.           if (algor->parameter == NULL) {
    109.               *pptype = V_ASN1_UNDEF;

crypto/asn1/x_algor.c:116:1: return from a call to X509_ALGOR_get0
    114.               *ppval = algor->parameter->value.ptr;
    115.       }
    116. > }
    117.   
    118.   /* Set up an X509_ALGOR DigestAlgorithmIdentifier from an EVP_MD */

crypto/cms/cms_lib.c:361:5: 
  359.       ASN1_OBJECT *mdoid;
  360.       X509_ALGOR_get0(&mdoid, NULL, NULL, mdalg);
  361. >     nid = OBJ_obj2nid(mdoid);
  362.       /* Look for digest type to match signature */
  363.       for (;;) {

crypto/objects/obj_dat.c:381:1: start of procedure OBJ_obj2nid()
    379.   IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
    380.   
    381. > int OBJ_obj2nid(const ASN1_OBJECT *a)
    382.   {
    383.       const unsigned int *op;

crypto/objects/obj_dat.c:386:9: Taking false branch
    384.       ADDED_OBJ ad, *adp;
    385.   
    386.       if (a == NULL)
                   ^
    387.           return (NID_undef);
    388.       if (a->nid != 0)

crypto/objects/obj_dat.c:388:9: Taking false branch
    386.       if (a == NULL)
    387.           return (NID_undef);
    388.       if (a->nid != 0)
                   ^
    389.           return (a->nid);
    390.   

crypto/objects/obj_dat.c:391:9: Taking false branch
    389.           return (a->nid);
    390.   
    391.       if (a->length == 0)
                   ^
    392.           return NID_undef;
    393.   

crypto/objects/obj_dat.c:394:9: Taking true branch
    392.           return NID_undef;
    393.   
    394.       if (added != NULL) {
                   ^
    395.           ad.type = ADDED_DATA;
    396.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */

crypto/objects/obj_dat.c:395:9: 
    393.   
    394.       if (added != NULL) {
    395. >         ad.type = ADDED_DATA;
    396.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
    397.           adp = lh_ADDED_OBJ_retrieve(added, &ad);

crypto/objects/obj_dat.c:396:9: 
    394.       if (added != NULL) {
    395.           ad.type = ADDED_DATA;
    396. >         ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
    397.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
    398.           if (adp != NULL)

crypto/objects/obj_dat.c:397:9: 
    395.           ad.type = ADDED_DATA;
    396.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
    397. >         adp = lh_ADDED_OBJ_retrieve(added, &ad);
    398.           if (adp != NULL)
    399.               return (adp->obj->nid);

crypto/objects/obj_lcl.h:7:1: start of procedure lh_ADDED_OBJ_retrieve()
      5.   DEFINE_LHASH_OF(OBJ_NAME);
      6.   typedef struct added_obj_st ADDED_OBJ;
      7. > DEFINE_LHASH_OF(ADDED_OBJ);

crypto/lhash/lhash.c:216:1: start of procedure lh_retrieve()
        214.   }
        215.   
        216. > void *lh_retrieve(_LHASH *lh, const void *data)
        217.   {
        218.       unsigned long hash;

crypto/lhash/lhash.c:222:5: 
        220.       void *ret;
        221.   
        222. >     lh->error = 0;
        223.       rn = getrn(lh, data, &hash);
        224.   

crypto/lhash/lhash.c:223:5: Skipping getrn(): empty list of specs
        221.   
        222.       lh->error = 0;
        223.       rn = getrn(lh, data, &hash);
                   ^
        224.   
        225.       if (*rn == NULL) {

crypto/lhash/lhash.c:225:9: Taking false branch
        223.       rn = getrn(lh, data, &hash);
        224.   
        225.       if (*rn == NULL) {
                       ^
        226.           lh->num_retrieve_miss++;
        227.           return (NULL);

crypto/lhash/lhash.c:229:9: 
        227.           return (NULL);
        228.       } else {
        229. >         ret = (*rn)->data;
        230.           lh->num_retrieve++;
        231.       }

crypto/lhash/lhash.c:230:9: 
        228.       } else {
        229.           ret = (*rn)->data;
        230. >         lh->num_retrieve++;
        231.       }
        232.       return (ret);

crypto/lhash/lhash.c:232:5: 
        230.           lh->num_retrieve++;
        231.       }
        232. >     return (ret);
        233.   }
        234.   

crypto/lhash/lhash.c:233:1: return from a call to lh_retrieve
        231.       }
        232.       return (ret);
        233. > }
        234.   
        235.   static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,

crypto/objects/obj_lcl.h:7:1: return from a call to lh_ADDED_OBJ_retrieve
      5.   DEFINE_LHASH_OF(OBJ_NAME);
      6.   typedef struct added_obj_st ADDED_OBJ;
      7. > DEFINE_LHASH_OF(ADDED_OBJ);

crypto/objects/obj_dat.c:398:13: Taking true branch
    396.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
    397.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
    398.           if (adp != NULL)
                       ^
    399.               return (adp->obj->nid);
    400.       }

crypto/objects/obj_dat.c:399:13: 
    397.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
    398.           if (adp != NULL)
    399. >             return (adp->obj->nid);
    400.       }
    401.       op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);

crypto/objects/obj_dat.c:405:1: return from a call to OBJ_obj2nid
    403.           return (NID_undef);
    404.       return (nid_objs[*op].nid);
    405. > }
    406.   
    407.   /*

crypto/cms/cms_lib.c:380:5: Loop condition is true. Entering loop body
  378.               return EVP_MD_CTX_copy_ex(mctx, mtmp);
  379.           chain = BIO_next(chain);
  380.       }
             ^
  381.   }
  382.   

crypto/cms/cms_lib.c:365:9: Skipping BIO_find_type(): empty list of specs
  363.       for (;;) {
  364.           EVP_MD_CTX *mtmp;
  365.           chain = BIO_find_type(chain, BIO_TYPE_MD);
                 ^
  366.           if (chain == NULL) {
  367.               CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX,

crypto/cms/cms_lib.c:366:13: Taking true branch
  364.           EVP_MD_CTX *mtmp;
  365.           chain = BIO_find_type(chain, BIO_TYPE_MD);
  366.           if (chain == NULL) {
                     ^
  367.               CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX,
  368.                      CMS_R_NO_MATCHING_DIGEST);

crypto/cms/cms_lib.c:367:13: Skipping ERR_put_error(): empty list of specs
  365.           chain = BIO_find_type(chain, BIO_TYPE_MD);
  366.           if (chain == NULL) {
  367.               CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX,
                     ^
  368.                      CMS_R_NO_MATCHING_DIGEST);
  369.               return 0;

crypto/cms/cms_lib.c:369:13: 
  367.               CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX,
  368.                      CMS_R_NO_MATCHING_DIGEST);
  369. >             return 0;
  370.           }
  371.           BIO_get_md_ctx(chain, &mtmp);

crypto/cms/cms_lib.c:381:1: return from a call to cms_DigestAlgorithm_find_ctx
  379.           chain = BIO_next(chain);
  380.       }
  381. > }
  382.   
  383.   static STACK_OF(CMS_CertificateChoices)

crypto/cms/cms_sd.c:843:10: Taking true branch
841.       }
842.   
843.       if (!cms_DigestAlgorithm_find_ctx(mctx, chain, si->digestAlgorithm))
                ^
844.           goto err;
845.   

crypto/cms/cms_sd.c:888:2: 
886.       }
887.   
888. >  err:
889.       EVP_PKEY_CTX_free(pkctx);
890.       EVP_MD_CTX_free(mctx);

crypto/cms/cms_sd.c:889:5: Skipping EVP_PKEY_CTX_free(): empty list of specs
887.   
888.    err:
889.       EVP_PKEY_CTX_free(pkctx);
           ^
890.       EVP_MD_CTX_free(mctx);
891.       return r;

crypto/cms/cms_sd.c:890:5: 
888.    err:
889.       EVP_PKEY_CTX_free(pkctx);
890. >     EVP_MD_CTX_free(mctx);
891.       return r;
892.   

crypto/evp/digest.c:157:1: start of procedure EVP_MD_CTX_free()
  155.   }
  156.   
  157. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  158.   {
  159.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:159:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  157.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  158.   {
  159.       EVP_MD_CTX_reset(ctx);
             ^
  160.       OPENSSL_free(ctx);
  161.   }

crypto/evp/digest.c:160:5: 
  158.   {
  159.       EVP_MD_CTX_reset(ctx);
  160. >     OPENSSL_free(ctx);
  161.   }
  162.   

crypto/mem.c:222:1: start of procedure CRYPTO_free()
    220.   }
    221.   
    222. > void CRYPTO_free(void *str, const char *file, int line)
    223.   {
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:224:9: Taking true branch
    222.   void CRYPTO_free(void *str, const char *file, int line)
    223.   {
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    225.           free_impl(str, file, line);
    226.           return;

crypto/mem.c:224:30: Taking true branch
    222.   void CRYPTO_free(void *str, const char *file, int line)
    223.   {
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    225.           free_impl(str, file, line);
    226.           return;

crypto/mem.c:225:9: Skipping __function_pointer__(): unresolved function pointer
    223.   {
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    225.           free_impl(str, file, line);
                   ^
    226.           return;
    227.       }

crypto/mem.c:226:9: 
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    225.           free_impl(str, file, line);
    226. >         return;
    227.       }
    228.   

crypto/mem.c:240:1: return from a call to CRYPTO_free
    238.       free(str);
    239.   #endif
    240. > }
    241.   
    242.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:161:1: return from a call to EVP_MD_CTX_free
  159.       EVP_MD_CTX_reset(ctx);
  160.       OPENSSL_free(ctx);
  161. > }
  162.   
  163.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
