crypto/cms/cms_pwri.c:342: error: MEMORY_LEAK
  memory dynamically allocated to `kekctx` by call to `EVP_CIPHER_CTX_new()` at line 334, column 14 is not reachable after line 342, column 10.
Showing all 52 steps of the trace


crypto/cms/cms_pwri.c:319:1: start of procedure cms_RecipientInfo_pwri_crypt()
317.   /* Encrypt/Decrypt content key in PWRI recipient info */
318.   
319. > int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
320.                                    int en_de)
321.   {

crypto/cms/cms_pwri.c:324:5: 
322.       CMS_EncryptedContentInfo *ec;
323.       CMS_PasswordRecipientInfo *pwri;
324. >     int r = 0;
325.       X509_ALGOR *algtmp, *kekalg = NULL;
326.       EVP_CIPHER_CTX *kekctx;

crypto/cms/cms_pwri.c:325:5: 
323.       CMS_PasswordRecipientInfo *pwri;
324.       int r = 0;
325. >     X509_ALGOR *algtmp, *kekalg = NULL;
326.       EVP_CIPHER_CTX *kekctx;
327.       const EVP_CIPHER *kekcipher;

crypto/cms/cms_pwri.c:328:5: 
326.       EVP_CIPHER_CTX *kekctx;
327.       const EVP_CIPHER *kekcipher;
328. >     unsigned char *key = NULL;
329.       size_t keylen;
330.   

crypto/cms/cms_pwri.c:331:5: 
329.       size_t keylen;
330.   
331. >     ec = cms->d.envelopedData->encryptedContentInfo;
332.   
333.       pwri = ri->d.pwri;

crypto/cms/cms_pwri.c:333:5: 
331.       ec = cms->d.envelopedData->encryptedContentInfo;
332.   
333. >     pwri = ri->d.pwri;
334.       kekctx = EVP_CIPHER_CTX_new();
335.   

crypto/cms/cms_pwri.c:334:5: 
332.   
333.       pwri = ri->d.pwri;
334. >     kekctx = EVP_CIPHER_CTX_new();
335.   
336.       if (!pwri->pass) {

crypto/evp/evp_enc.c:93:1: start of procedure EVP_CIPHER_CTX_new()
  91.   }
  92.   
  93. > EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void)
  94.   {
  95.       return OPENSSL_zalloc(sizeof(EVP_CIPHER_CTX));

crypto/evp/evp_enc.c:95:5: 
  93.   EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void)
  94.   {
  95. >     return OPENSSL_zalloc(sizeof(EVP_CIPHER_CTX));
  96.   }
  97.   

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/evp_enc.c:96:1: return from a call to EVP_CIPHER_CTX_new
  94.   {
  95.       return OPENSSL_zalloc(sizeof(EVP_CIPHER_CTX));
  96. > }
  97.   
  98.   void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)

crypto/cms/cms_pwri.c:336:10: Taking false branch
334.       kekctx = EVP_CIPHER_CTX_new();
335.   
336.       if (!pwri->pass) {
                ^
337.           CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, CMS_R_NO_PASSWORD);
338.           return 0;

crypto/cms/cms_pwri.c:340:5: 
338.           return 0;
339.       }
340. >     algtmp = pwri->keyEncryptionAlgorithm;
341.   
342.       if (!algtmp || OBJ_obj2nid(algtmp->algorithm) != NID_id_alg_PWRI_KEK) {

crypto/cms/cms_pwri.c:342:10: Taking false branch
340.       algtmp = pwri->keyEncryptionAlgorithm;
341.   
342.       if (!algtmp || OBJ_obj2nid(algtmp->algorithm) != NID_id_alg_PWRI_KEK) {
                ^
343.           CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT,
344.                  CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM);

crypto/cms/cms_pwri.c:342:20: 
340.       algtmp = pwri->keyEncryptionAlgorithm;
341.   
342. >     if (!algtmp || OBJ_obj2nid(algtmp->algorithm) != NID_id_alg_PWRI_KEK) {
343.           CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT,
344.                  CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM);

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_pwri.c:342:20: Taking true branch
340.       algtmp = pwri->keyEncryptionAlgorithm;
341.   
342.       if (!algtmp || OBJ_obj2nid(algtmp->algorithm) != NID_id_alg_PWRI_KEK) {
                          ^
343.           CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT,
344.                  CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM);
