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


crypto/cms/cms_sd.c:533:1: start of procedure cms_SignerInfo_content_sign()
531.   }
532.   
533. > static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms,
534.                                          CMS_SignerInfo *si, BIO *chain)
535.   {

crypto/cms/cms_sd.c:536:5: 
534.                                          CMS_SignerInfo *si, BIO *chain)
535.   {
536. >     EVP_MD_CTX *mctx = EVP_MD_CTX_new();
537.       int r = 0;
538.       EVP_PKEY_CTX *pctx = NULL;

crypto/evp/digest.c:44:1: start of procedure EVP_MD_CTX_new()
  42.   }
  43.   
  44. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:46:5: 
  44.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47.   }
  48.   

crypto/mem.c:98:1: start of procedure CRYPTO_zalloc()
    96.   }
    97.   
    98. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:100:5: 
    98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100. >     void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
      69.   }
      70.   
      71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73.       void *ret = NULL;

crypto/mem.c:73:5: 
      71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73. >     void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
      73.       void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                    ^
      76.           return malloc_impl(num, file, line);
      77.   

crypto/mem.c:78:9: Taking false branch
      76.           return malloc_impl(num, file, line);
      77.   
      78.       if (num <= 0)
                    ^
      79.           return NULL;
      80.   

crypto/mem.c:81:5: 
      79.           return NULL;
      80.   
      81. >     allow_customize = 0;
      82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:91:24: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:92:5: 
      90.   #else
      91.       osslargused(file); osslargused(line);
      92. >     ret = malloc(num);
      93.   #endif
      94.   

crypto/mem.c:95:5: 
      93.   #endif
      94.   
      95. >     return ret;
      96.   }
      97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
      94.   
      95.       return ret;
      96. > }
      97.   
      98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:102:9: Taking true branch
    100.       void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)
                   ^
    103.           memset(ret, 0, num);
    104.       return ret;

crypto/mem.c:103:9: 
    101.   
    102.       if (ret != NULL)
    103. >         memset(ret, 0, num);
    104.       return ret;
    105.   }

crypto/mem.c:104:5: 
    102.       if (ret != NULL)
    103.           memset(ret, 0, num);
    104. >     return ret;
    105.   }
    106.   

crypto/mem.c:105:1: return from a call to CRYPTO_zalloc
    103.           memset(ret, 0, num);
    104.       return ret;
    105. > }
    106.   
    107.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:47:1: return from a call to EVP_MD_CTX_new
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47. > }
  48.   
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/cms/cms_sd.c:537:5: 
535.   {
536.       EVP_MD_CTX *mctx = EVP_MD_CTX_new();
537. >     int r = 0;
538.       EVP_PKEY_CTX *pctx = NULL;
539.   

crypto/cms/cms_sd.c:538:5: 
536.       EVP_MD_CTX *mctx = EVP_MD_CTX_new();
537.       int r = 0;
538. >     EVP_PKEY_CTX *pctx = NULL;
539.   
540.       if (mctx == NULL) {

crypto/cms/cms_sd.c:540:9: Taking false branch
538.       EVP_PKEY_CTX *pctx = NULL;
539.   
540.       if (mctx == NULL) {
               ^
541.           CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, ERR_R_MALLOC_FAILURE);
542.           return 0;

crypto/cms/cms_sd.c:545:10: Taking false branch
543.       }
544.   
545.       if (!si->pkey) {
                ^
546.           CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, CMS_R_NO_PRIVATE_KEY);
547.           goto err;

crypto/cms/cms_sd.c:550:10: 
548.       }
549.   
550. >     if (!cms_DigestAlgorithm_find_ctx(mctx, chain, si->digestAlgorithm))
551.           goto err;
552.       /* Set SignerInfo algorithm details if we used custom parameter */

crypto/cms/cms_lib.c:311:1: start of procedure cms_DigestAlgorithm_find_ctx()
  309.   /* Locate a message digest content from a BIO chain based on SignerInfo */
  310.   
  311. > int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
  312.                                    X509_ALGOR *mdalg)
  313.   {

crypto/cms/cms_lib.c:316:5: 
  314.       int nid;
  315.       ASN1_OBJECT *mdoid;
  316. >     X509_ALGOR_get0(&mdoid, NULL, NULL, mdalg);
  317.       nid = OBJ_obj2nid(mdoid);
  318.       /* Look for digest type to match signature */

crypto/asn1/x_algor.c:53:1: start of procedure X509_ALGOR_get0()
    51.   }
    52.   
    53. > void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
    54.                        X509_ALGOR *algor)
    55.   {

crypto/asn1/x_algor.c:56:9: Taking true branch
    54.                        X509_ALGOR *algor)
    55.   {
    56.       if (paobj)
                  ^
    57.           *paobj = algor->algorithm;
    58.       if (pptype) {

crypto/asn1/x_algor.c:57:9: 
    55.   {
    56.       if (paobj)
    57. >         *paobj = algor->algorithm;
    58.       if (pptype) {
    59.           if (algor->parameter == NULL) {

crypto/asn1/x_algor.c:58:9: Taking false branch
    56.       if (paobj)
    57.           *paobj = algor->algorithm;
    58.       if (pptype) {
                  ^
    59.           if (algor->parameter == NULL) {
    60.               *pptype = V_ASN1_UNDEF;

crypto/asn1/x_algor.c:58:5: 
    56.       if (paobj)
    57.           *paobj = algor->algorithm;
    58. >     if (pptype) {
    59.           if (algor->parameter == NULL) {
    60.               *pptype = V_ASN1_UNDEF;

crypto/asn1/x_algor.c:67:1: return from a call to X509_ALGOR_get0
    65.               *ppval = algor->parameter->value.ptr;
    66.       }
    67. > }
    68.   
    69.   /* Set up an X509_ALGOR DigestAlgorithmIdentifier from an EVP_MD */

crypto/cms/cms_lib.c:317:5: 
  315.       ASN1_OBJECT *mdoid;
  316.       X509_ALGOR_get0(&mdoid, NULL, NULL, mdalg);
  317. >     nid = OBJ_obj2nid(mdoid);
  318.       /* Look for digest type to match signature */
  319.       for (;;) {

crypto/objects/obj_dat.c:317:1: start of procedure OBJ_obj2nid()
    315.   IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
    316.   
    317. > int OBJ_obj2nid(const ASN1_OBJECT *a)
    318.   {
    319.       const unsigned int *op;

crypto/objects/obj_dat.c:322:9: Taking false branch
    320.       ADDED_OBJ ad, *adp;
    321.   
    322.       if (a == NULL)
                   ^
    323.           return (NID_undef);
    324.       if (a->nid != 0)

crypto/objects/obj_dat.c:324:9: Taking false branch
    322.       if (a == NULL)
    323.           return (NID_undef);
    324.       if (a->nid != 0)
                   ^
    325.           return (a->nid);
    326.   

crypto/objects/obj_dat.c:327:9: Taking false branch
    325.           return (a->nid);
    326.   
    327.       if (a->length == 0)
                   ^
    328.           return NID_undef;
    329.   

crypto/objects/obj_dat.c:330:9: Taking true branch
    328.           return NID_undef;
    329.   
    330.       if (added != NULL) {
                   ^
    331.           ad.type = ADDED_DATA;
    332.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */

crypto/objects/obj_dat.c:331:9: 
    329.   
    330.       if (added != NULL) {
    331. >         ad.type = ADDED_DATA;
    332.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
    333.           adp = lh_ADDED_OBJ_retrieve(added, &ad);

crypto/objects/obj_dat.c:332:9: 
    330.       if (added != NULL) {
    331.           ad.type = ADDED_DATA;
    332. >         ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
    333.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
    334.           if (adp != NULL)

crypto/objects/obj_dat.c:333:9: 
    331.           ad.type = ADDED_DATA;
    332.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
    333. >         adp = lh_ADDED_OBJ_retrieve(added, &ad);
    334.           if (adp != NULL)
    335.               return (adp->obj->nid);

crypto/objects/obj_lcl.h:14:1: start of procedure lh_ADDED_OBJ_retrieve()
      12.   DEFINE_LHASH_OF(OBJ_NAME);
      13.   typedef struct added_obj_st ADDED_OBJ;
      14. > DEFINE_LHASH_OF(ADDED_OBJ);

crypto/lhash/lhash.c:131:1: start of procedure OPENSSL_LH_retrieve()
        129.   }
        130.   
        131. > void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data)
        132.   {
        133.       unsigned long hash;

crypto/lhash/lhash.c:137:5: 
        135.       void *ret;
        136.   
        137. >     lh->error = 0;
        138.       rn = getrn(lh, data, &hash);
        139.   

crypto/lhash/lhash.c:138:5: Skipping getrn(): empty list of specs
        136.   
        137.       lh->error = 0;
        138.       rn = getrn(lh, data, &hash);
                   ^
        139.   
        140.       if (*rn == NULL) {

crypto/lhash/lhash.c:140:9: Taking false branch
        138.       rn = getrn(lh, data, &hash);
        139.   
        140.       if (*rn == NULL) {
                       ^
        141.           lh->num_retrieve_miss++;
        142.           return (NULL);

crypto/lhash/lhash.c:144:9: 
        142.           return (NULL);
        143.       } else {
        144. >         ret = (*rn)->data;
        145.           lh->num_retrieve++;
        146.       }

crypto/lhash/lhash.c:145:9: 
        143.       } else {
        144.           ret = (*rn)->data;
        145. >         lh->num_retrieve++;
        146.       }
        147.       return (ret);

crypto/lhash/lhash.c:147:5: 
        145.           lh->num_retrieve++;
        146.       }
        147. >     return (ret);
        148.   }
        149.   

crypto/lhash/lhash.c:148:1: return from a call to OPENSSL_LH_retrieve
        146.       }
        147.       return (ret);
        148. > }
        149.   
        150.   static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,

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

crypto/objects/obj_dat.c:334:13: Taking true branch
    332.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
    333.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
    334.           if (adp != NULL)
                       ^
    335.               return (adp->obj->nid);
    336.       }

crypto/objects/obj_dat.c:335:13: 
    333.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
    334.           if (adp != NULL)
    335. >             return (adp->obj->nid);
    336.       }
    337.       op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);

crypto/objects/obj_dat.c:341:1: return from a call to OBJ_obj2nid
    339.           return (NID_undef);
    340.       return (nid_objs[*op].nid);
    341. > }
    342.   
    343.   /*

crypto/cms/cms_lib.c:336:5: Loop condition is true. Entering loop body
  334.               return EVP_MD_CTX_copy_ex(mctx, mtmp);
  335.           chain = BIO_next(chain);
  336.       }
             ^
  337.   }
  338.   

crypto/cms/cms_lib.c:321:9: Skipping BIO_find_type(): empty list of specs
  319.       for (;;) {
  320.           EVP_MD_CTX *mtmp;
  321.           chain = BIO_find_type(chain, BIO_TYPE_MD);
                 ^
  322.           if (chain == NULL) {
  323.               CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX,

crypto/cms/cms_lib.c:322:13: Taking true branch
  320.           EVP_MD_CTX *mtmp;
  321.           chain = BIO_find_type(chain, BIO_TYPE_MD);
  322.           if (chain == NULL) {
                     ^
  323.               CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX,
  324.                      CMS_R_NO_MATCHING_DIGEST);

crypto/cms/cms_lib.c:323:13: Skipping ERR_put_error(): empty list of specs
  321.           chain = BIO_find_type(chain, BIO_TYPE_MD);
  322.           if (chain == NULL) {
  323.               CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX,
                     ^
  324.                      CMS_R_NO_MATCHING_DIGEST);
  325.               return 0;

crypto/cms/cms_lib.c:325:13: 
  323.               CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX,
  324.                      CMS_R_NO_MATCHING_DIGEST);
  325. >             return 0;
  326.           }
  327.           BIO_get_md_ctx(chain, &mtmp);

crypto/cms/cms_lib.c:337:1: return from a call to cms_DigestAlgorithm_find_ctx
  335.           chain = BIO_next(chain);
  336.       }
  337. > }
  338.   
  339.   static STACK_OF(CMS_CertificateChoices)

crypto/cms/cms_sd.c:550:10: Taking true branch
548.       }
549.   
550.       if (!cms_DigestAlgorithm_find_ctx(mctx, chain, si->digestAlgorithm))
                ^
551.           goto err;
552.       /* Set SignerInfo algorithm details if we used custom parameter */

crypto/cms/cms_sd.c:613:2: 
611.       r = 1;
612.   
613. >  err:
614.       EVP_MD_CTX_free(mctx);
615.       EVP_PKEY_CTX_free(pctx);

crypto/cms/cms_sd.c:614:5: 
612.   
613.    err:
614. >     EVP_MD_CTX_free(mctx);
615.       EVP_PKEY_CTX_free(pctx);
616.       return r;

crypto/evp/digest.c:49:1: start of procedure EVP_MD_CTX_free()
  47.   }
  48.   
  49. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:51:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
            ^
  52.       OPENSSL_free(ctx);
  53.   }

crypto/evp/digest.c:52:5: 
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
  52. >     OPENSSL_free(ctx);
  53.   }
  54.   

crypto/mem.c:163:1: start of procedure CRYPTO_free()
    161.   }
    162.   
    163. > void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:165:9: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:165:30: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:166:9: Skipping __function_pointer__(): unresolved function pointer
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
                   ^
    167.           return;
    168.       }

crypto/mem.c:167:9: 
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
    167. >         return;
    168.       }
    169.   

crypto/mem.c:181:1: return from a call to CRYPTO_free
    179.       free(str);
    180.   #endif
    181. > }
    182.   
    183.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:53:1: return from a call to EVP_MD_CTX_free
  51.       EVP_MD_CTX_reset(ctx);
  52.       OPENSSL_free(ctx);
  53. > }
  54.   
  55.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
