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


crypto/err/err.c:697:1: start of procedure ERR_get_state()
695.   }
696.   
697. > ERR_STATE *ERR_get_state(void)
698.   {
699.       ERR_STATE *state;

crypto/err/err.c:700:5: 
698.   {
699.       ERR_STATE *state;
700. >     int saveerrno = get_last_sys_error();
701.   
702.       if (!OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL))

crypto/err/err.c:702:10: Taking false branch
700.       int saveerrno = get_last_sys_error();
701.   
702.       if (!OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL))
                ^
703.           return NULL;
704.   

crypto/err/err.c:705:10: 
703.           return NULL;
704.   
705. >     if (!RUN_ONCE(&err_init, err_do_init))
706.           return NULL;
707.   

crypto/threads_pthread.c:111:1: start of procedure CRYPTO_THREAD_run_once()
  109.   }
  110.   
  111. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
  112.   {
  113.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:113:9: Taking false branch
  111.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
  112.   {
  113.       if (pthread_once(once, init) != 0)
                 ^
  114.           return 0;
  115.   

crypto/threads_pthread.c:116:5: 
  114.           return 0;
  115.   
  116. >     return 1;
  117.   }
  118.   

crypto/threads_pthread.c:117:1: return from a call to CRYPTO_THREAD_run_once
  115.   
  116.       return 1;
  117. > }
  118.   
  119.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/err/err.c:705:10: Condition is true
703.           return NULL;
704.   
705.       if (!RUN_ONCE(&err_init, err_do_init))
                ^
706.           return NULL;
707.   

crypto/err/err.c:705:10: Taking false branch
703.           return NULL;
704.   
705.       if (!RUN_ONCE(&err_init, err_do_init))
                ^
706.           return NULL;
707.   

crypto/err/err.c:708:5: 
706.           return NULL;
707.   
708. >     state = CRYPTO_THREAD_get_local(&err_thread_local);
709.       if (state == (ERR_STATE*)-1)
710.           return NULL;

crypto/threads_pthread.c:127:1: start of procedure CRYPTO_THREAD_get_local()
  125.   }
  126.   
  127. > void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
  128.   {
  129.       return pthread_getspecific(*key);

crypto/threads_pthread.c:129:5: Skipping pthread_getspecific(): method has no implementation
  127.   void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
  128.   {
  129.       return pthread_getspecific(*key);
             ^
  130.   }
  131.   

crypto/threads_pthread.c:130:1: return from a call to CRYPTO_THREAD_get_local
  128.   {
  129.       return pthread_getspecific(*key);
  130. > }
  131.   
  132.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)

crypto/err/err.c:709:9: Taking false branch
707.   
708.       state = CRYPTO_THREAD_get_local(&err_thread_local);
709.       if (state == (ERR_STATE*)-1)
               ^
710.           return NULL;
711.   

crypto/err/err.c:712:9: Taking true branch
710.           return NULL;
711.   
712.       if (state == NULL) {
               ^
713.           if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))
714.               return NULL;

crypto/err/err.c:713:14: 
711.   
712.       if (state == NULL) {
713. >         if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))
714.               return NULL;
715.   

crypto/threads_pthread.c:132:1: start of procedure CRYPTO_THREAD_set_local()
  130.   }
  131.   
  132. > int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
  133.   {
  134.       if (pthread_setspecific(*key, val) != 0)

crypto/threads_pthread.c:134:9: Taking false branch
  132.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
  133.   {
  134.       if (pthread_setspecific(*key, val) != 0)
                 ^
  135.           return 0;
  136.   

crypto/threads_pthread.c:137:5: 
  135.           return 0;
  136.   
  137. >     return 1;
  138.   }
  139.   

crypto/threads_pthread.c:138:1: return from a call to CRYPTO_THREAD_set_local
  136.   
  137.       return 1;
  138. > }
  139.   
  140.   int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)

crypto/err/err.c:713:14: Taking false branch
711.   
712.       if (state == NULL) {
713.           if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))
                    ^
714.               return NULL;
715.   

crypto/err/err.c:716:13: 
714.               return NULL;
715.   
716. >         if ((state = OPENSSL_zalloc(sizeof(*state))) == NULL) {
717.               CRYPTO_THREAD_set_local(&err_thread_local, NULL);
718.               return NULL;

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/err/err.c:716:13: Taking false branch
714.               return NULL;
715.   
716.           if ((state = OPENSSL_zalloc(sizeof(*state))) == NULL) {
                   ^
717.               CRYPTO_THREAD_set_local(&err_thread_local, NULL);
718.               return NULL;

crypto/err/err.c:721:14: Taking false branch
719.           }
720.   
721.           if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
                    ^
722.                   || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
723.               ERR_STATE_free(state);

crypto/err/err.c:722:21: 
720.   
721.           if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
722. >                 || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
723.               ERR_STATE_free(state);
724.               CRYPTO_THREAD_set_local(&err_thread_local, NULL);

crypto/threads_pthread.c:132:1: start of procedure CRYPTO_THREAD_set_local()
  130.   }
  131.   
  132. > int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
  133.   {
  134.       if (pthread_setspecific(*key, val) != 0)

crypto/threads_pthread.c:134:9: Taking true branch
  132.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
  133.   {
  134.       if (pthread_setspecific(*key, val) != 0)
                 ^
  135.           return 0;
  136.   

crypto/threads_pthread.c:135:9: 
  133.   {
  134.       if (pthread_setspecific(*key, val) != 0)
  135. >         return 0;
  136.   
  137.       return 1;

crypto/threads_pthread.c:138:1: return from a call to CRYPTO_THREAD_set_local
  136.   
  137.       return 1;
  138. > }
  139.   
  140.   int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)

crypto/err/err.c:722:21: Taking true branch
720.   
721.           if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
722.                   || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
                           ^
723.               ERR_STATE_free(state);
724.               CRYPTO_THREAD_set_local(&err_thread_local, NULL);

crypto/err/err.c:723:13: Skipping ERR_STATE_free(): empty list of specs
721.           if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
722.                   || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
723.               ERR_STATE_free(state);
                   ^
724.               CRYPTO_THREAD_set_local(&err_thread_local, NULL);
725.               return NULL;

ERR_STATE *ERR_get_state(void)
{
    ERR_STATE *state;
    int saveerrno = get_last_sys_error();
    if (!OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL))
        return NULL;
    if (!RUN_ONCE(&err_init, err_do_init))
        return NULL;
    state = CRYPTO_THREAD_get_local(&err_thread_local);
    if (state == (ERR_STATE*)-1)
        return NULL;
    if (state == NULL) {
        if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))
            return NULL;
        if ((state = OPENSSL_zalloc(sizeof(*state))) == NULL) {
            CRYPTO_THREAD_set_local(&err_thread_local, 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);
            CRYPTO_THREAD_set_local(&err_thread_local, NULL);
            return NULL;
        }
        OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
    }
    set_sys_error(saveerrno);
    return state;
}
['ERR_STATE *ERR_get_state(void)\n{\n    ERR_STATE *state;\n    int saveerrno = get_last_sys_error();\n    if (!OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL))\n        return 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 == (ERR_STATE*)-1)\n        return NULL;\n    if (state == NULL) {\n        if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))\n            return NULL;\n        if ((state = OPENSSL_zalloc(sizeof(*state))) == NULL) {\n            CRYPTO_THREAD_set_local(&err_thread_local, NULL);\n            return NULL;\n        }\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            CRYPTO_THREAD_set_local(&err_thread_local, NULL);\n            return NULL;\n        }\n        OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);\n    }\n    set_sys_error(saveerrno);\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}', 'int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)\n{\n    if (pthread_setspecific(*key, val) != 0)\n        return 0;\n    return 1;\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    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}']