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


crypto/pem/pvkfmt.c:627:1: start of procedure derive_pvk_key()
625.   }
626.   
627. > static int derive_pvk_key(unsigned char *key,
628.                             const unsigned char *salt, unsigned int saltlen,
629.                             const unsigned char *pass, int passlen)

crypto/pem/pvkfmt.c:631:5: 
629.                             const unsigned char *pass, int passlen)
630.   {
631. >     EVP_MD_CTX *mctx = EVP_MD_CTX_new();
632.       int rv = 1;
633.       if (mctx == NULL

crypto/evp/digest.c:147:1: start of procedure EVP_MD_CTX_new()
  145.   }
  146.   
  147. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  148.   {
  149.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:149:5: 
  147.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  148.   {
  149. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  150.   }
  151.   

crypto/mem.c:146:1: start of procedure CRYPTO_zalloc()
    144.   }
    145.   
    146. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:148:5: 
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148. >     void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       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:143:5: 
      141.   #endif
      142.   
      143. >     return ret;
      144.   }
      145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
      142.   
      143.       return ret;
      144. > }
      145.   
      146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:150:9: Taking true branch
    148.       void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)
                   ^
    151.           memset(ret, 0, num);
    152.       return ret;

crypto/mem.c:151:9: 
    149.   
    150.       if (ret != NULL)
    151. >         memset(ret, 0, num);
    152.       return ret;
    153.   }

crypto/mem.c:152:5: 
    150.       if (ret != NULL)
    151.           memset(ret, 0, num);
    152. >     return ret;
    153.   }
    154.   

crypto/mem.c:153:1: return from a call to CRYPTO_zalloc
    151.           memset(ret, 0, num);
    152.       return ret;
    153. > }
    154.   
    155.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:150:1: return from a call to EVP_MD_CTX_new
  148.   {
  149.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  150. > }
  151.   
  152.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/pem/pvkfmt.c:632:5: 
630.   {
631.       EVP_MD_CTX *mctx = EVP_MD_CTX_new();
632. >     int rv = 1;
633.       if (mctx == NULL
634.           || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)

crypto/pem/pvkfmt.c:633:9: Taking false branch
631.       EVP_MD_CTX *mctx = EVP_MD_CTX_new();
632.       int rv = 1;
633.       if (mctx == NULL
               ^
634.           || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
635.           || !EVP_DigestUpdate(mctx, salt, saltlen)

crypto/pem/pvkfmt.c:634:13: 
632.       int rv = 1;
633.       if (mctx == NULL
634. >         || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
635.           || !EVP_DigestUpdate(mctx, salt, saltlen)
636.           || !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:634:13: Taking false branch
632.       int rv = 1;
633.       if (mctx == NULL
634.           || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
                   ^
635.           || !EVP_DigestUpdate(mctx, salt, saltlen)
636.           || !EVP_DigestUpdate(mctx, pass, passlen)

crypto/pem/pvkfmt.c:635:13: 
633.       if (mctx == NULL
634.           || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
635. >         || !EVP_DigestUpdate(mctx, salt, saltlen)
636.           || !EVP_DigestUpdate(mctx, pass, passlen)
637.           || !EVP_DigestFinal_ex(mctx, key, NULL))

crypto/evp/digest.c:249:1: start of procedure EVP_DigestUpdate()
  247.   }
  248.   
  249. > int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
  250.   {
  251.       return ctx->update(ctx, data, count);

crypto/evp/digest.c:251:5: Skipping __function_pointer__(): unresolved function pointer
  249.   int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
  250.   {
  251.       return ctx->update(ctx, data, count);
             ^
  252.   }
  253.   

crypto/evp/digest.c:252:1: return from a call to EVP_DigestUpdate
  250.   {
  251.       return ctx->update(ctx, data, count);
  252. > }
  253.   
  254.   /* The caller can assume that this removes any secret data from the context */

crypto/pem/pvkfmt.c:635:13: Taking true branch
633.       if (mctx == NULL
634.           || !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
635.           || !EVP_DigestUpdate(mctx, salt, saltlen)
                   ^
636.           || !EVP_DigestUpdate(mctx, pass, passlen)
637.           || !EVP_DigestFinal_ex(mctx, key, NULL))

crypto/pem/pvkfmt.c:638:9: 
636.           || !EVP_DigestUpdate(mctx, pass, passlen)
637.           || !EVP_DigestFinal_ex(mctx, key, NULL))
638. >         rv = 0;
639.   
640.       EVP_MD_CTX_free(mctx);

crypto/pem/pvkfmt.c:640:5: 
638.           rv = 0;
639.   
640. >     EVP_MD_CTX_free(mctx);
641.       return rv;
642.   }

crypto/evp/digest.c:152:1: start of procedure EVP_MD_CTX_free()
  150.   }
  151.   
  152. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  153.   {
  154.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:154:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  152.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  153.   {
  154.       EVP_MD_CTX_reset(ctx);
             ^
  155.       OPENSSL_free(ctx);
  156.   }

crypto/evp/digest.c:155:5: 
  153.   {
  154.       EVP_MD_CTX_reset(ctx);
  155. >     OPENSSL_free(ctx);
  156.   }
  157.   

crypto/mem.c:210:1: start of procedure CRYPTO_free()
    208.   }
    209.   
    210. > void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:212:9: Taking true branch
    210.   void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    213.           free_impl(str, file, line);
    214.           return;

crypto/mem.c:212:30: Taking true branch
    210.   void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    213.           free_impl(str, file, line);
    214.           return;

crypto/mem.c:213:9: Skipping __function_pointer__(): unresolved function pointer
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    213.           free_impl(str, file, line);
                   ^
    214.           return;
    215.       }

crypto/mem.c:214:9: 
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    213.           free_impl(str, file, line);
    214. >         return;
    215.       }
    216.   

crypto/mem.c:228:1: return from a call to CRYPTO_free
    226.       free(str);
    227.   #endif
    228. > }
    229.   
    230.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:156:1: return from a call to EVP_MD_CTX_free
  154.       EVP_MD_CTX_reset(ctx);
  155.       OPENSSL_free(ctx);
  156. > }
  157.   
  158.   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    return ret;\n}', 'const EVP_MD *EVP_sha1(void)\n{\n    return (&sha1_md);\n}', 'int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)\n{\n    return ctx->update(ctx, data, count);\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}']