crypto/err/err.c:687: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_zalloc()` at line 681, column 17 is not reachable after line 687, column 13.
Showing all 39 steps of the trace


crypto/err/err.c:671:1: start of procedure ERR_get_state()
669.   }
670.   
671. > ERR_STATE *ERR_get_state(void)
672.   {
673.       ERR_STATE *state = NULL;

crypto/err/err.c:673:5: 
671.   ERR_STATE *ERR_get_state(void)
672.   {
673. >     ERR_STATE *state = NULL;
674.   
675.       if (!RUN_ONCE(&err_init, err_do_init))

crypto/err/err.c:675:10: 
673.       ERR_STATE *state = NULL;
674.   
675. >     if (!RUN_ONCE(&err_init, err_do_init))
676.           return NULL;
677.   

crypto/threads_pthread.c:104:1: start of procedure CRYPTO_THREAD_run_once()
  102.   }
  103.   
  104. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
  105.   {
  106.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:106:9: Taking false branch
  104.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
  105.   {
  106.       if (pthread_once(once, init) != 0)
                 ^
  107.           return 0;
  108.   

crypto/threads_pthread.c:109:5: 
  107.           return 0;
  108.   
  109. >     return 1;
  110.   }
  111.   

crypto/threads_pthread.c:110:1: return from a call to CRYPTO_THREAD_run_once
  108.   
  109.       return 1;
  110. > }
  111.   
  112.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/err/err.c:675:10: Condition is true
673.       ERR_STATE *state = NULL;
674.   
675.       if (!RUN_ONCE(&err_init, err_do_init))
                ^
676.           return NULL;
677.   

crypto/err/err.c:675:10: Taking false branch
673.       ERR_STATE *state = NULL;
674.   
675.       if (!RUN_ONCE(&err_init, err_do_init))
                ^
676.           return NULL;
677.   

crypto/err/err.c:678:5: 
676.           return NULL;
677.   
678. >     state = CRYPTO_THREAD_get_local(&err_thread_local);
679.   
680.       if (state == NULL) {

crypto/threads_pthread.c:120:1: start of procedure CRYPTO_THREAD_get_local()
  118.   }
  119.   
  120. > void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
  121.   {
  122.       return pthread_getspecific(*key);

crypto/threads_pthread.c:122:5: Skipping pthread_getspecific(): method has no implementation
  120.   void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
  121.   {
  122.       return pthread_getspecific(*key);
             ^
  123.   }
  124.   

crypto/threads_pthread.c:123:1: return from a call to CRYPTO_THREAD_get_local
  121.   {
  122.       return pthread_getspecific(*key);
  123. > }
  124.   
  125.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)

crypto/err/err.c:680:9: Taking true branch
678.       state = CRYPTO_THREAD_get_local(&err_thread_local);
679.   
680.       if (state == NULL) {
               ^
681.           state = OPENSSL_zalloc(sizeof(*state));
682.           if (state == NULL)

crypto/err/err.c:681:9: 
679.   
680.       if (state == NULL) {
681. >         state = OPENSSL_zalloc(sizeof(*state));
682.           if (state == NULL)
683.               return NULL;

crypto/mem.c:186:1: start of procedure CRYPTO_zalloc()
  184.   }
  185.   
  186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  187.   {
  188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
  186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  187.   {
  188. >     void *ret = CRYPTO_malloc(num, file, line);
  189.   
  190.       FAILTEST();

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
    156.   #endif
    157.   
    158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    159.   {
    160.       void *ret = NULL;

crypto/mem.c:160:5: 
    158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    159.   {
    160. >     void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
    160.       void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    163.           return malloc_impl(num, file, line);
    164.   

crypto/mem.c:165:9: Taking false branch
    163.           return malloc_impl(num, file, line);
    164.   
    165.       if (num == 0)
                   ^
    166.           return NULL;
    167.   

crypto/mem.c:169:5: 
    167.   
    168.       FAILTEST();
    169. >     allow_customize = 0;
    170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
    177.       }
    178.   #else
    179. >     osslargused(file); osslargused(line);
    180.       ret = malloc(num);
    181.   #endif

crypto/mem.c:179:24: 
    177.       }
    178.   #else
    179. >     osslargused(file); osslargused(line);
    180.       ret = malloc(num);
    181.   #endif

crypto/mem.c:180:5: 
    178.   #else
    179.       osslargused(file); osslargused(line);
    180. >     ret = malloc(num);
    181.   #endif
    182.   

crypto/mem.c:183:5: 
    181.   #endif
    182.   
    183. >     return ret;
    184.   }
    185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
    182.   
    183.       return ret;
    184. > }
    185.   
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
  189.   
  190.       FAILTEST();
  191.       if (ret != NULL)
                 ^
  192.           memset(ret, 0, num);
  193.       return ret;

crypto/mem.c:192:9: 
  190.       FAILTEST();
  191.       if (ret != NULL)
  192. >         memset(ret, 0, num);
  193.       return ret;
  194.   }

crypto/mem.c:193:5: 
  191.       if (ret != NULL)
  192.           memset(ret, 0, num);
  193. >     return ret;
  194.   }
  195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
  192.           memset(ret, 0, num);
  193.       return ret;
  194. > }
  195.   
  196.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/err/err.c:682:13: Taking false branch
680.       if (state == NULL) {
681.           state = OPENSSL_zalloc(sizeof(*state));
682.           if (state == NULL)
                   ^
683.               return NULL;
684.   

crypto/err/err.c:685:14: 
683.               return NULL;
684.   
685. >         if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
686.               || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
687.               ERR_STATE_free(state);

crypto/init.c:350:1: start of procedure ossl_init_thread_start()
  348.   }
  349.   
  350. > int ossl_init_thread_start(uint64_t opts)
  351.   {
  352.       struct thread_local_inits_st *locals;

crypto/init.c:354:10: Taking true branch
  352.       struct thread_local_inits_st *locals;
  353.   
  354.       if (!OPENSSL_init_crypto(0, NULL))
                  ^
  355.           return 0;
  356.   

crypto/init.c:355:9: 
  353.   
  354.       if (!OPENSSL_init_crypto(0, NULL))
  355. >         return 0;
  356.   
  357.       locals = ossl_init_get_thread_local(1);

crypto/init.c:379:1: return from a call to ossl_init_thread_start
  377.   
  378.       return 1;
  379. > }
  380.   
  381.   void OPENSSL_cleanup(void)

crypto/err/err.c:685:14: Taking true branch
683.               return NULL;
684.   
685.           if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
                    ^
686.               || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
687.               ERR_STATE_free(state);

crypto/err/err.c:687:13: Skipping ERR_STATE_free(): empty list of specs
685.           if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
686.               || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
687.               ERR_STATE_free(state);
                   ^
688.               return NULL;
689.           }

ERR_STATE *ERR_get_state(void)
{
    ERR_STATE *state = NULL;
    if (!RUN_ONCE(&err_init, err_do_init))
        return NULL;
    state = CRYPTO_THREAD_get_local(&err_thread_local);
    if (state == NULL) {
        state = OPENSSL_zalloc(sizeof(*state));
        if (state == NULL)
            return NULL;
        if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
            || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
            ERR_STATE_free(state);
            return NULL;
        }
        OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
    }
    return state;
}
['ERR_STATE *ERR_get_state(void)\n{\n    ERR_STATE *state = NULL;\n    if (!RUN_ONCE(&err_init, err_do_init))\n        return NULL;\n    state = CRYPTO_THREAD_get_local(&err_thread_local);\n    if (state == NULL) {\n        state = OPENSSL_zalloc(sizeof(*state));\n        if (state == NULL)\n            return NULL;\n        if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)\n            || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {\n            ERR_STATE_free(state);\n            return NULL;\n        }\n        OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);\n    }\n    return state;\n}', 'int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))\n{\n    if (pthread_once(once, init) != 0)\n        return 0;\n    return 1;\n}', 'void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)\n{\n    return pthread_getspecific(*key);\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\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    FAILTEST();\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}', 'int ossl_init_thread_start(uint64_t opts)\n{\n    struct thread_local_inits_st *locals;\n    if (!OPENSSL_init_crypto(0, NULL))\n        return 0;\n    locals = ossl_init_get_thread_local(1);\n    if (locals == NULL)\n        return 0;\n    if (opts & OPENSSL_INIT_THREAD_ASYNC) {\n#ifdef OPENSSL_INIT_DEBUG\n        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "\n                        "marking thread for async\\n");\n#endif\n        locals->async = 1;\n    }\n    if (opts & OPENSSL_INIT_THREAD_ERR_STATE) {\n#ifdef OPENSSL_INIT_DEBUG\n        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "\n                        "marking thread for err_state\\n");\n#endif\n        locals->err_state = 1;\n    }\n    return 1;\n}']