crypto/dh/dh_kdf.c:190: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 154, column 12 is not reachable after line 190, column 5.
Showing all 55 steps of the trace


crypto/dh/dh_kdf.c:141:1: start of procedure DH_KDF_X9_42()
139.   }
140.   
141. > int DH_KDF_X9_42(unsigned char *out, size_t outlen,
142.                    const unsigned char *Z, size_t Zlen,
143.                    ASN1_OBJECT *key_oid,

crypto/dh/dh_kdf.c:146:5: 
144.                    const unsigned char *ukm, size_t ukmlen, const EVP_MD *md)
145.   {
146. >     EVP_MD_CTX *mctx = NULL;
147.       int rv = 0;
148.       unsigned int i;

crypto/dh/dh_kdf.c:147:5: 
145.   {
146.       EVP_MD_CTX *mctx = NULL;
147. >     int rv = 0;
148.       unsigned int i;
149.       size_t mdlen;

crypto/dh/dh_kdf.c:150:5: 
148.       unsigned int i;
149.       size_t mdlen;
150. >     unsigned char *der = NULL, *ctr;
151.       int derlen;
152.       if (Zlen > DH_KDF_MAX)

crypto/dh/dh_kdf.c:152:9: Taking false branch
150.       unsigned char *der = NULL, *ctr;
151.       int derlen;
152.       if (Zlen > DH_KDF_MAX)
               ^
153.           return 0;
154.       mctx = EVP_MD_CTX_new();

crypto/dh/dh_kdf.c:154:5: 
152.       if (Zlen > DH_KDF_MAX)
153.           return 0;
154. >     mctx = EVP_MD_CTX_new();
155.       if (mctx == NULL)
156.           return 0;

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:159:1: start of procedure CRYPTO_zalloc()
    157.   }
    158.   
    159. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    160.   {
    161.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:161:5: 
    159.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    160.   {
    161. >     void *ret = CRYPTO_malloc(num, file, line);
    162.   
    163.       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. >     (void)file;
      140.       (void)line;
      141.       ret = malloc(num);

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

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

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

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

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

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

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

crypto/mem.c:166:1: return from a call to CRYPTO_zalloc
    164.           memset(ret, 0, num);
    165.       return ret;
    166. > }
    167.   
    168.   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/dh/dh_kdf.c:155:9: Taking false branch
153.           return 0;
154.       mctx = EVP_MD_CTX_new();
155.       if (mctx == NULL)
               ^
156.           return 0;
157.       mdlen = EVP_MD_size(md);

crypto/dh/dh_kdf.c:157:5: 
155.       if (mctx == NULL)
156.           return 0;
157. >     mdlen = EVP_MD_size(md);
158.       derlen = dh_sharedinfo_encode(&der, &ctr, key_oid, outlen, ukm, ukmlen);
159.       if (derlen == 0)

crypto/evp/evp_lib.c:339:1: start of procedure EVP_MD_size()
  337.   }
  338.   
  339. > int EVP_MD_size(const EVP_MD *md)
  340.   {
  341.       if (!md) {

crypto/evp/evp_lib.c:341:10: Taking false branch
  339.   int EVP_MD_size(const EVP_MD *md)
  340.   {
  341.       if (!md) {
                  ^
  342.           EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
  343.           return -1;

crypto/evp/evp_lib.c:345:5: 
  343.           return -1;
  344.       }
  345. >     return md->md_size;
  346.   }
  347.   

crypto/evp/evp_lib.c:346:1: return from a call to EVP_MD_size
  344.       }
  345.       return md->md_size;
  346. > }
  347.   
  348.   unsigned long EVP_MD_flags(const EVP_MD *md)

crypto/dh/dh_kdf.c:158:5: 
156.           return 0;
157.       mdlen = EVP_MD_size(md);
158. >     derlen = dh_sharedinfo_encode(&der, &ctr, key_oid, outlen, ukm, ukmlen);
159.       if (derlen == 0)
160.           goto err;

crypto/dh/dh_kdf.c:92:1: start of procedure dh_sharedinfo_encode()
  90.    */
  91.   
  92. > static int dh_sharedinfo_encode(unsigned char **pder, unsigned char **pctr,
  93.                                   ASN1_OBJECT *key_oid, size_t outlen,
  94.                                   const unsigned char *ukm, size_t ukmlen)

crypto/dh/dh_kdf.c:100:5: 
  98.       long tlen;
  99.       /* "magic" value to check offset is sane */
  100. >     static unsigned char ctr[4] = { 0xF3, 0x17, 0x22, 0x53 };
  101.       X509_ALGOR atmp;
  102.       ASN1_OCTET_STRING ctr_oct, ukm_oct, *pukm_oct;

crypto/dh/dh_kdf.c:104:9: Taking true branch
  102.       ASN1_OCTET_STRING ctr_oct, ukm_oct, *pukm_oct;
  103.       ASN1_TYPE ctr_atype;
  104.       if (ukmlen > DH_KDF_MAX || outlen > DH_KDF_MAX)
                 ^
  105.           return 0;
  106.       ctr_oct.data = ctr;

crypto/dh/dh_kdf.c:105:9: 
  103.       ASN1_TYPE ctr_atype;
  104.       if (ukmlen > DH_KDF_MAX || outlen > DH_KDF_MAX)
  105. >         return 0;
  106.       ctr_oct.data = ctr;
  107.       ctr_oct.length = 4;

crypto/dh/dh_kdf.c:139:1: return from a call to dh_sharedinfo_encode
  137.       *pctr = p;
  138.       return derlen;
  139. > }
  140.   
  141.   int DH_KDF_X9_42(unsigned char *out, size_t outlen,

crypto/dh/dh_kdf.c:159:9: Taking true branch
157.       mdlen = EVP_MD_size(md);
158.       derlen = dh_sharedinfo_encode(&der, &ctr, key_oid, outlen, ukm, ukmlen);
159.       if (derlen == 0)
               ^
160.           goto err;
161.       for (i = 1;; i++) {

crypto/dh/dh_kdf.c:188:2: 
186.       }
187.       rv = 1;
188. >  err:
189.       OPENSSL_free(der);
190.       EVP_MD_CTX_free(mctx);

crypto/dh/dh_kdf.c:189:5: 
187.       rv = 1;
188.    err:
189. >     OPENSSL_free(der);
190.       EVP_MD_CTX_free(mctx);
191.       return rv;

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

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

crypto/mem.c:241:5: 
  239.       }
  240.   #else
  241. >     free(str);
  242.   #endif
  243.   }

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

crypto/dh/dh_kdf.c:190:5: 
188.    err:
189.       OPENSSL_free(der);
190. >     EVP_MD_CTX_free(mctx);
191.       return rv;
192.   }

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:225:1: start of procedure CRYPTO_free()
    223.   }
    224.   
    225. > void CRYPTO_free(void *str, const char *file, int line)
    226.   {
    227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

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

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

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

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

crypto/mem.c:243:1: return from a call to CRYPTO_free
    241.       free(str);
    242.   #endif
    243. > }
    244.   
    245.   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)
