crypto/pem/pvkfmt.c:633: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 624, column 24 is not reachable after line 633, column 5.
Showing all 40 steps of the trace


crypto/pem/pvkfmt.c:620:1: start of procedure derive_pvk_key()
618.   }
619.   
620. > static int derive_pvk_key(unsigned char *key,
621.                             const unsigned char *salt, unsigned int saltlen,
622.                             const unsigned char *pass, int passlen)

crypto/pem/pvkfmt.c:624:5: 
622.                             const unsigned char *pass, int passlen)
623.   {
624. >     EVP_MD_CTX *mctx = EVP_MD_CTX_new();
625.       int rv = 1;
626.       if (mctx == NULL

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: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/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/pem/pvkfmt.c:625:5: 
623.   {
624.       EVP_MD_CTX *mctx = EVP_MD_CTX_new();
625. >     int rv = 1;
626.       if (mctx == NULL
627.           || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)

crypto/pem/pvkfmt.c:626:9: Taking false branch
624.       EVP_MD_CTX *mctx = EVP_MD_CTX_new();
625.       int rv = 1;
626.       if (mctx == NULL
               ^
627.           || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
628.           || !EVP_DigestUpdate(mctx, salt, saltlen)

crypto/pem/pvkfmt.c:627:13: 
625.       int rv = 1;
626.       if (mctx == NULL
627. >         || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
628.           || !EVP_DigestUpdate(mctx, salt, saltlen)
629.           || !EVP_DigestUpdate(mctx, pass, passlen)

crypto/evp/m_sha1.c:153:1: start of procedure EVP_sha1()
  151.   };
  152.   
  153. > const EVP_MD *EVP_sha1(void)
  154.   {
  155.       return (&sha1_md);

crypto/evp/m_sha1.c:155:5: 
  153.   const EVP_MD *EVP_sha1(void)
  154.   {
  155. >     return (&sha1_md);
  156.   }
  157.   

crypto/evp/m_sha1.c:156:1: return from a call to EVP_sha1
  154.   {
  155.       return (&sha1_md);
  156. > }
  157.   
  158.   static int init224(EVP_MD_CTX *ctx)

crypto/pem/pvkfmt.c:627:13: Taking true branch
625.       int rv = 1;
626.       if (mctx == NULL
627.           || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
                   ^
628.           || !EVP_DigestUpdate(mctx, salt, saltlen)
629.           || !EVP_DigestUpdate(mctx, pass, passlen)

crypto/pem/pvkfmt.c:631:9: 
629.           || !EVP_DigestUpdate(mctx, pass, passlen)
630.           || !EVP_DigestFinal_ex(mctx, key, NULL))
631. >         rv = 0;
632.   
633.       EVP_MD_CTX_free(mctx);

crypto/pem/pvkfmt.c:633:5: 
631.           rv = 0;
632.   
633. >     EVP_MD_CTX_free(mctx);
634.       return rv;
635.   }

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

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

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

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

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

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

static int derive_pvk_key(unsigned char *key,
                          const unsigned char *salt, unsigned int saltlen,
                          const unsigned char *pass, int passlen)
{
    EVP_MD_CTX *mctx = EVP_MD_CTX_new();
    int rv = 1;
    if (mctx == NULL
        || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
        || !EVP_DigestUpdate(mctx, salt, saltlen)
        || !EVP_DigestUpdate(mctx, pass, passlen)
        || !EVP_DigestFinal_ex(mctx, key, NULL))
        rv = 0;
    EVP_MD_CTX_free(mctx);
    return rv;
}
['static int derive_pvk_key(unsigned char *key,\n                          const unsigned char *salt, unsigned int saltlen,\n                          const unsigned char *pass, int passlen)\n{\n    EVP_MD_CTX *mctx = EVP_MD_CTX_new();\n    int rv = 1;\n    if (mctx == NULL\n        || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)\n        || !EVP_DigestUpdate(mctx, salt, saltlen)\n        || !EVP_DigestUpdate(mctx, pass, passlen)\n        || !EVP_DigestFinal_ex(mctx, key, NULL))\n        rv = 0;\n    EVP_MD_CTX_free(mctx);\n    return rv;\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'const EVP_MD *EVP_sha1(void)\n{\n    return (&sha1_md);\n}', 'void EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']