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


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

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

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

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

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

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

crypto/cms/cms_pwri.c:335:5: 
333.   
334.       pwri = ri->d.pwri;
335. >     kekctx = EVP_CIPHER_CTX_new();
336.   
337.       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:157:1: start of procedure CRYPTO_zalloc()
    155.   }
    156.   
    157. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    158.   {
    159.       void *ret = CRYPTO_malloc(num, file, line);

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

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

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

crypto/mem.c:124:9: Taking false branch
      122.       void *ret = NULL;
      123.   
      124.       if (num <= 0)
                     ^
      125.           return NULL;
      126.   

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

crypto/mem.c:137:5: 
      135.       }
      136.   #else
      137. >     (void)file;
      138.       (void)line;
      139.       ret = malloc(num);

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

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

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

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

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

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

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

crypto/mem.c:164:1: return from a call to CRYPTO_zalloc
    162.           memset(ret, 0, num);
    163.       return ret;
    164. > }
    165.   
    166.   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:337:10: Taking false branch
335.       kekctx = EVP_CIPHER_CTX_new();
336.   
337.       if (!pwri->pass) {
                ^
338.           CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, CMS_R_NO_PASSWORD);
339.           return 0;

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

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

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

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

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

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

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

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

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

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

crypto/objects/obj_dat.c:398:9: 
  396.           ad.type = ADDED_DATA;
  397.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  398. >         adp = lh_ADDED_OBJ_retrieve(added, &ad);
  399.           if (adp != NULL)
  400.               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:217:1: start of procedure lh_retrieve()
      215.   }
      216.   
      217. > void *lh_retrieve(_LHASH *lh, const void *data)
      218.   {
      219.       unsigned long hash;

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

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

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

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

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

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

crypto/lhash/lhash.c:234:1: return from a call to lh_retrieve
      232.       }
      233.       return (ret);
      234. > }
      235.   
      236.   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:399:13: Taking true branch
  397.           ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */
  398.           adp = lh_ADDED_OBJ_retrieve(added, &ad);
  399.           if (adp != NULL)
                     ^
  400.               return (adp->obj->nid);
  401.       }

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

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

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