crypto/kdf/tls1_prf.c:266: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 260, column 20 is not reachable after line 266, column 13.
Showing all 41 steps of the trace


crypto/kdf/tls1_prf.c:247:1: start of procedure tls1_prf_alg()
245.   }
246.   
247. > static int tls1_prf_alg(const EVP_MD *md,
248.                           const unsigned char *sec, size_t slen,
249.                           const unsigned char *seed, size_t seed_len,

crypto/kdf/tls1_prf.c:253:9: 
251.   {
252.   
253. >     if (EVP_MD_type(md) == NID_md5_sha1) {
254.           size_t i;
255.           unsigned char *tmp;

crypto/evp/evp_lib.c:291:1: start of procedure EVP_MD_type()
  289.   }
  290.   
  291. > int EVP_MD_type(const EVP_MD *md)
  292.   {
  293.       return md->type;

crypto/evp/evp_lib.c:293:5: 
  291.   int EVP_MD_type(const EVP_MD *md)
  292.   {
  293. >     return md->type;
  294.   }
  295.   

crypto/evp/evp_lib.c:294:1: return from a call to EVP_MD_type
  292.   {
  293.       return md->type;
  294. > }
  295.   
  296.   int EVP_MD_pkey_type(const EVP_MD *md)

crypto/kdf/tls1_prf.c:253:9: Taking true branch
251.   {
252.   
253.       if (EVP_MD_type(md) == NID_md5_sha1) {
               ^
254.           size_t i;
255.           unsigned char *tmp;

crypto/kdf/tls1_prf.c:256:14: 
254.           size_t i;
255.           unsigned char *tmp;
256. >         if (!tls1_prf_P_hash(EVP_md5(), sec, slen/2 + (slen & 1),
257.                            seed, seed_len, out, olen))
258.               return 0;

crypto/evp/m_md5.c:51:1: start of procedure EVP_md5()
  49.   };
  50.   
  51. > const EVP_MD *EVP_md5(void)
  52.   {
  53.       return &md5_md;

crypto/evp/m_md5.c:53:5: 
  51.   const EVP_MD *EVP_md5(void)
  52.   {
  53. >     return &md5_md;
  54.   }
  55.   #endif

crypto/evp/m_md5.c:54:1: return from a call to EVP_md5
  52.   {
  53.       return &md5_md;
  54. > }
  55.   #endif

crypto/kdf/tls1_prf.c:256:14: Taking false branch
254.           size_t i;
255.           unsigned char *tmp;
256.           if (!tls1_prf_P_hash(EVP_md5(), sec, slen/2 + (slen & 1),
                    ^
257.                            seed, seed_len, out, olen))
258.               return 0;

crypto/kdf/tls1_prf.c:260:13: 
258.               return 0;
259.   
260. >         if ((tmp = OPENSSL_malloc(olen)) == NULL) {
261.               KDFerr(KDF_F_TLS1_PRF_ALG, ERR_R_MALLOC_FAILURE);
262.               return 0;

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 false branch
  202.   
  203.       FAILTEST();
  204.       if (allow_customize) {
                 ^
  205.           /*
  206.            * Disallow customization after the first allocation. We only set this

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/kdf/tls1_prf.c:260:13: Taking false branch
258.               return 0;
259.   
260.           if ((tmp = OPENSSL_malloc(olen)) == NULL) {
                   ^
261.               KDFerr(KDF_F_TLS1_PRF_ALG, ERR_R_MALLOC_FAILURE);
262.               return 0;

crypto/kdf/tls1_prf.c:264:14: 
262.               return 0;
263.           }
264. >         if (!tls1_prf_P_hash(EVP_sha1(), sec + slen/2, slen/2 + (slen & 1),
265.                            seed, seed_len, tmp, olen)) {
266.               OPENSSL_clear_free(tmp, olen);

crypto/evp/m_sha1.c:109:1: start of procedure EVP_sha1()
  107.   };
  108.   
  109. > const EVP_MD *EVP_sha1(void)
  110.   {
  111.       return &sha1_md;

crypto/evp/m_sha1.c:111:5: 
  109.   const EVP_MD *EVP_sha1(void)
  110.   {
  111. >     return &sha1_md;
  112.   }
  113.   

crypto/evp/m_sha1.c:112:1: return from a call to EVP_sha1
  110.   {
  111.       return &sha1_md;
  112. > }
  113.   
  114.   static int init224(EVP_MD_CTX *ctx)

crypto/kdf/tls1_prf.c:264:14: Taking true branch
262.               return 0;
263.           }
264.           if (!tls1_prf_P_hash(EVP_sha1(), sec + slen/2, slen/2 + (slen & 1),
                    ^
265.                            seed, seed_len, tmp, olen)) {
266.               OPENSSL_clear_free(tmp, olen);

crypto/kdf/tls1_prf.c:266:13: 
264.           if (!tls1_prf_P_hash(EVP_sha1(), sec + slen/2, slen/2 + (slen & 1),
265.                            seed, seed_len, tmp, olen)) {
266. >             OPENSSL_clear_free(tmp, olen);
267.               return 0;
268.           }

crypto/mem.c:316:1: start of procedure CRYPTO_clear_free()
  314.   }
  315.   
  316. > void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  317.   {
  318.       if (str == NULL)

crypto/mem.c:318:9: Taking false branch
  316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  317.   {
  318.       if (str == NULL)
                 ^
  319.           return;
  320.       if (num)

crypto/mem.c:320:9: Taking true branch
  318.       if (str == NULL)
  319.           return;
  320.       if (num)
                 ^
  321.           OPENSSL_cleanse(str, num);
  322.       CRYPTO_free(str, file, line);

crypto/mem.c:321:9: Skipping OPENSSL_cleanse(): method has no implementation
  319.           return;
  320.       if (num)
  321.           OPENSSL_cleanse(str, num);
                 ^
  322.       CRYPTO_free(str, file, line);
  323.   }

crypto/mem.c:322:5: 
  320.       if (num)
  321.           OPENSSL_cleanse(str, num);
  322. >     CRYPTO_free(str, file, line);
  323.   }

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/mem.c:323:1: return from a call to CRYPTO_clear_free
  321.           OPENSSL_cleanse(str, num);
  322.       CRYPTO_free(str, file, line);
  323. > }

static int tls1_prf_alg(const EVP_MD *md,
                        const unsigned char *sec, size_t slen,
                        const unsigned char *seed, size_t seed_len,
                        unsigned char *out, size_t olen)
{
    if (EVP_MD_type(md) == NID_md5_sha1) {
        size_t i;
        unsigned char *tmp;
        if (!tls1_prf_P_hash(EVP_md5(), sec, slen/2 + (slen & 1),
                         seed, seed_len, out, olen))
            return 0;
        if ((tmp = OPENSSL_malloc(olen)) == NULL) {
            KDFerr(KDF_F_TLS1_PRF_ALG, ERR_R_MALLOC_FAILURE);
            return 0;
        }
        if (!tls1_prf_P_hash(EVP_sha1(), sec + slen/2, slen/2 + (slen & 1),
                         seed, seed_len, tmp, olen)) {
            OPENSSL_clear_free(tmp, olen);
            return 0;
        }
        for (i = 0; i < olen; i++)
            out[i] ^= tmp[i];
        OPENSSL_clear_free(tmp, olen);
        return 1;
    }
    if (!tls1_prf_P_hash(md, sec, slen, seed, seed_len, out, olen))
        return 0;
    return 1;
}
['static int tls1_prf_alg(const EVP_MD *md,\n                        const unsigned char *sec, size_t slen,\n                        const unsigned char *seed, size_t seed_len,\n                        unsigned char *out, size_t olen)\n{\n    if (EVP_MD_type(md) == NID_md5_sha1) {\n        size_t i;\n        unsigned char *tmp;\n        if (!tls1_prf_P_hash(EVP_md5(), sec, slen/2 + (slen & 1),\n                         seed, seed_len, out, olen))\n            return 0;\n        if ((tmp = OPENSSL_malloc(olen)) == NULL) {\n            KDFerr(KDF_F_TLS1_PRF_ALG, ERR_R_MALLOC_FAILURE);\n            return 0;\n        }\n        if (!tls1_prf_P_hash(EVP_sha1(), sec + slen/2, slen/2 + (slen & 1),\n                         seed, seed_len, tmp, olen)) {\n            OPENSSL_clear_free(tmp, olen);\n            return 0;\n        }\n        for (i = 0; i < olen; i++)\n            out[i] ^= tmp[i];\n        OPENSSL_clear_free(tmp, olen);\n        return 1;\n    }\n    if (!tls1_prf_P_hash(md, sec, slen, seed, seed_len, out, olen))\n        return 0;\n    return 1;\n}', 'int EVP_MD_type(const EVP_MD *md)\n{\n    return md->type;\n}', 'const EVP_MD *EVP_md5(void)\n{\n    return &md5_md;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\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    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'const EVP_MD *EVP_sha1(void)\n{\n    return &sha1_md;\n}', 'void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)\n{\n    if (str == NULL)\n        return;\n    if (num)\n        OPENSSL_cleanse(str, num);\n    CRYPTO_free(str, file, line);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    INCREMENT(free_count);\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}']