crypto/ec/ecdh_kdf.c:66: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 31, column 12 is not reachable after line 66, column 5.
Showing all 57 steps of the trace


crypto/ec/ecdh_kdf.c:18:1: start of procedure ECDH_KDF_X9_62()
16.   #define ECDH_KDF_MAX    (1 << 30)
17.   
18. > int ECDH_KDF_X9_62(unsigned char *out, size_t outlen,
19.                      const unsigned char *Z, size_t Zlen,
20.                      const unsigned char *sinfo, size_t sinfolen,

crypto/ec/ecdh_kdf.c:23:5: 
21.                      const EVP_MD *md)
22.   {
23. >     EVP_MD_CTX *mctx = NULL;
24.       int rv = 0;
25.       unsigned int i;

crypto/ec/ecdh_kdf.c:24:5: 
22.   {
23.       EVP_MD_CTX *mctx = NULL;
24. >     int rv = 0;
25.       unsigned int i;
26.       size_t mdlen;

crypto/ec/ecdh_kdf.c:28:9: Taking false branch
26.       size_t mdlen;
27.       unsigned char ctr[4];
28.       if (sinfolen > ECDH_KDF_MAX || outlen > ECDH_KDF_MAX
              ^
29.           || Zlen > ECDH_KDF_MAX)
30.           return 0;

crypto/ec/ecdh_kdf.c:28:36: Taking false branch
26.       size_t mdlen;
27.       unsigned char ctr[4];
28.       if (sinfolen > ECDH_KDF_MAX || outlen > ECDH_KDF_MAX
                                         ^
29.           || Zlen > ECDH_KDF_MAX)
30.           return 0;

crypto/ec/ecdh_kdf.c:29:12: Taking false branch
27.       unsigned char ctr[4];
28.       if (sinfolen > ECDH_KDF_MAX || outlen > ECDH_KDF_MAX
29.           || Zlen > ECDH_KDF_MAX)
                 ^
30.           return 0;
31.       mctx = EVP_MD_CTX_new();

crypto/ec/ecdh_kdf.c:31:5: 
29.           || Zlen > ECDH_KDF_MAX)
30.           return 0;
31. >     mctx = EVP_MD_CTX_new();
32.       if (mctx == NULL)
33.           return 0;

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:228:1: start of procedure CRYPTO_zalloc()
    226.   }
    227.   
    228. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:230:5: 
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230. >     void *ret = CRYPTO_malloc(num, file, line);
    231.   
    232.       FAILTEST();

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
      190.   #endif
      191.   
      192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194.       void *ret = NULL;

crypto/mem.c:194:5: 
      192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194. >     void *ret = NULL;
      195.   
      196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
      195.   
      196.       INCREMENT(malloc_count);
      197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      198.           return malloc_impl(num, file, line);
      199.   

crypto/mem.c:200:9: Taking false branch
      198.           return malloc_impl(num, file, line);
      199.   
      200.       if (num == 0)
                     ^
      201.           return NULL;
      202.   

crypto/mem.c:204:9: Taking true branch
      202.   
      203.       FAILTEST();
      204.       if (allow_customize) {
                     ^
      205.           /*
      206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
      208.            * allocation.
      209.            */
      210. >         allow_customize = 0;
      211.       }
      212.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:221:5: 
      219.       }
      220.   #else
      221. >     (void)(file); (void)(line);
      222.       ret = malloc(num);
      223.   #endif

crypto/mem.c:221:19: 
      219.       }
      220.   #else
      221. >     (void)(file); (void)(line);
      222.       ret = malloc(num);
      223.   #endif

crypto/mem.c:222:5: 
      220.   #else
      221.       (void)(file); (void)(line);
      222. >     ret = malloc(num);
      223.   #endif
      224.   

crypto/mem.c:225:5: 
      223.   #endif
      224.   
      225. >     return ret;
      226.   }
      227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
      224.   
      225.       return ret;
      226. > }
      227.   
      228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:233:9: Taking true branch
    231.   
    232.       FAILTEST();
    233.       if (ret != NULL)
                   ^
    234.           memset(ret, 0, num);
    235.       return ret;

crypto/mem.c:234:9: 
    232.       FAILTEST();
    233.       if (ret != NULL)
    234. >         memset(ret, 0, num);
    235.       return ret;
    236.   }

crypto/mem.c:235:5: 
    233.       if (ret != NULL)
    234.           memset(ret, 0, num);
    235. >     return ret;
    236.   }
    237.   

crypto/mem.c:236:1: return from a call to CRYPTO_zalloc
    234.           memset(ret, 0, num);
    235.       return ret;
    236. > }
    237.   
    238.   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/ec/ecdh_kdf.c:32:9: Taking false branch
30.           return 0;
31.       mctx = EVP_MD_CTX_new();
32.       if (mctx == NULL)
              ^
33.           return 0;
34.       mdlen = EVP_MD_size(md);

crypto/ec/ecdh_kdf.c:34:5: 
32.       if (mctx == NULL)
33.           return 0;
34. >     mdlen = EVP_MD_size(md);
35.       for (i = 1;; i++) {
36.           unsigned char mtmp[EVP_MAX_MD_SIZE];

crypto/evp/evp_lib.c:301:1: start of procedure EVP_MD_size()
  299.   }
  300.   
  301. > int EVP_MD_size(const EVP_MD *md)
  302.   {
  303.       if (!md) {

crypto/evp/evp_lib.c:303:10: Taking false branch
  301.   int EVP_MD_size(const EVP_MD *md)
  302.   {
  303.       if (!md) {
                  ^
  304.           EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
  305.           return -1;

crypto/evp/evp_lib.c:307:5: 
  305.           return -1;
  306.       }
  307. >     return md->md_size;
  308.   }
  309.   

crypto/evp/evp_lib.c:308:1: return from a call to EVP_MD_size
  306.       }
  307.       return md->md_size;
  308. > }
  309.   
  310.   unsigned long EVP_MD_flags(const EVP_MD *md)

crypto/ec/ecdh_kdf.c:35:10: 
33.           return 0;
34.       mdlen = EVP_MD_size(md);
35. >     for (i = 1;; i++) {
36.           unsigned char mtmp[EVP_MAX_MD_SIZE];
37.           if (!EVP_DigestInit_ex(mctx, md, NULL))

crypto/ec/ecdh_kdf.c:35:14: Loop condition is true. Entering loop body
33.           return 0;
34.       mdlen = EVP_MD_size(md);
35.       for (i = 1;; i++) {
                   ^
36.           unsigned char mtmp[EVP_MAX_MD_SIZE];
37.           if (!EVP_DigestInit_ex(mctx, md, NULL))

crypto/ec/ecdh_kdf.c:37:14: Taking false branch
35.       for (i = 1;; i++) {
36.           unsigned char mtmp[EVP_MAX_MD_SIZE];
37.           if (!EVP_DigestInit_ex(mctx, md, NULL))
                   ^
38.               goto err;
39.           ctr[3] = i & 0xFF;

crypto/ec/ecdh_kdf.c:39:9: 
37.           if (!EVP_DigestInit_ex(mctx, md, NULL))
38.               goto err;
39. >         ctr[3] = i & 0xFF;
40.           ctr[2] = (i >> 8) & 0xFF;
41.           ctr[1] = (i >> 16) & 0xFF;

crypto/ec/ecdh_kdf.c:40:9: 
38.               goto err;
39.           ctr[3] = i & 0xFF;
40. >         ctr[2] = (i >> 8) & 0xFF;
41.           ctr[1] = (i >> 16) & 0xFF;
42.           ctr[0] = (i >> 24) & 0xFF;

crypto/ec/ecdh_kdf.c:41:9: 
39.           ctr[3] = i & 0xFF;
40.           ctr[2] = (i >> 8) & 0xFF;
41. >         ctr[1] = (i >> 16) & 0xFF;
42.           ctr[0] = (i >> 24) & 0xFF;
43.           if (!EVP_DigestUpdate(mctx, Z, Zlen))

crypto/ec/ecdh_kdf.c:42:9: 
40.           ctr[2] = (i >> 8) & 0xFF;
41.           ctr[1] = (i >> 16) & 0xFF;
42. >         ctr[0] = (i >> 24) & 0xFF;
43.           if (!EVP_DigestUpdate(mctx, Z, Zlen))
44.               goto err;

crypto/ec/ecdh_kdf.c:43:14: 
41.           ctr[1] = (i >> 16) & 0xFF;
42.           ctr[0] = (i >> 24) & 0xFF;
43. >         if (!EVP_DigestUpdate(mctx, Z, Zlen))
44.               goto err;
45.           if (!EVP_DigestUpdate(mctx, ctr, sizeof(ctr)))

crypto/evp/digest.c:146:1: start of procedure EVP_DigestUpdate()
  144.   }
  145.   
  146. > int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
  147.   {
  148.       return ctx->update(ctx, data, count);

crypto/evp/digest.c:148:5: Skipping __function_pointer__(): unresolved function pointer
  146.   int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
  147.   {
  148.       return ctx->update(ctx, data, count);
             ^
  149.   }
  150.   

crypto/evp/digest.c:149:1: return from a call to EVP_DigestUpdate
  147.   {
  148.       return ctx->update(ctx, data, count);
  149. > }
  150.   
  151.   /* The caller can assume that this removes any secret data from the context */

crypto/ec/ecdh_kdf.c:43:14: Taking true branch
41.           ctr[1] = (i >> 16) & 0xFF;
42.           ctr[0] = (i >> 24) & 0xFF;
43.           if (!EVP_DigestUpdate(mctx, Z, Zlen))
                   ^
44.               goto err;
45.           if (!EVP_DigestUpdate(mctx, ctr, sizeof(ctr)))

crypto/ec/ecdh_kdf.c:65:2: 
63.       }
64.       rv = 1;
65. >  err:
66.       EVP_MD_CTX_free(mctx);
67.       return rv;

crypto/ec/ecdh_kdf.c:66:5: 
64.       rv = 1;
65.    err:
66. >     EVP_MD_CTX_free(mctx);
67.       return rv;
68.   }

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:295:1: start of procedure CRYPTO_free()
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:298:30: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:299:9: Skipping __function_pointer__(): unresolved function pointer
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
                   ^
    300.           return;
    301.       }

crypto/mem.c:300:9: 
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
    300. >         return;
    301.       }
    302.   

crypto/mem.c:314:1: return from a call to CRYPTO_free
    312.       free(str);
    313.   #endif
    314. > }
    315.   
    316.   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)
