crypto/err/err.c:481: error: MEMORY_LEAK
  memory dynamically allocated by call to `ERR_get_state()` at line 476, column 10 is not reachable after line 481, column 13.
Showing all 51 steps of the trace


crypto/err/err.c:468:1: start of procedure get_error_values()
466.   }
467.   
468. > static unsigned long get_error_values(int inc, int top, const char **file,
469.                                         int *line, const char **data,
470.                                         int *flags)

crypto/err/err.c:472:5: 
470.                                         int *flags)
471.   {
472. >     int i = 0;
473.       ERR_STATE *es;
474.       unsigned long ret;

crypto/err/err.c:476:5: 
474.       unsigned long ret;
475.   
476. >     es = ERR_get_state();
477.       if (es == NULL)
478.           return 0;

crypto/err/err.c:664:1: start of procedure ERR_get_state()
  662.   }
  663.   
  664. > ERR_STATE *ERR_get_state(void)
  665.   {
  666.       ERR_STATE *state = NULL;

crypto/err/err.c:666:5: 
  664.   ERR_STATE *ERR_get_state(void)
  665.   {
  666. >     ERR_STATE *state = NULL;
  667.   
  668.       if (!RUN_ONCE(&err_init, err_do_init))

crypto/err/err.c:668:10: 
  666.       ERR_STATE *state = NULL;
  667.   
  668. >     if (!RUN_ONCE(&err_init, err_do_init))
  669.           return NULL;
  670.   

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

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

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

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

crypto/err/err.c:668:10: Condition is true
  666.       ERR_STATE *state = NULL;
  667.   
  668.       if (!RUN_ONCE(&err_init, err_do_init))
                  ^
  669.           return NULL;
  670.   

crypto/err/err.c:668:10: Taking false branch
  666.       ERR_STATE *state = NULL;
  667.   
  668.       if (!RUN_ONCE(&err_init, err_do_init))
                  ^
  669.           return NULL;
  670.   

crypto/err/err.c:676:10: Taking false branch
  674.        * Needed on any platform that doesn't define OPENSSL_USE_NODELETE.
  675.        */
  676.       if (!OPENSSL_init_crypto(0, NULL))
                  ^
  677.           return NULL;
  678.   

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

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

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

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

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

crypto/err/err.c:682:9: 
  680.   
  681.       if (state == NULL) {
  682. >         state = OPENSSL_zalloc(sizeof(*state));
  683.           if (state == NULL)
  684.               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:683:13: Taking false branch
  681.       if (state == NULL) {
  682.           state = OPENSSL_zalloc(sizeof(*state));
  683.           if (state == NULL)
                     ^
  684.               return NULL;
  685.   

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

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

crypto/threads_pthread.c:126:1: start of procedure CRYPTO_THREAD_set_local()
    124.   }
    125.   
    126. > int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
    127.   {
    128.       if (pthread_setspecific(*key, val) != 0)

crypto/threads_pthread.c:128:9: Taking false branch
    126.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
    127.   {
    128.       if (pthread_setspecific(*key, val) != 0)
                   ^
    129.           return 0;
    130.   

crypto/threads_pthread.c:131:5: 
    129.           return 0;
    130.   
    131. >     return 1;
    132.   }
    133.   

crypto/threads_pthread.c:132:1: return from a call to CRYPTO_THREAD_set_local
    130.   
    131.       return 1;
    132. > }
    133.   
    134.   int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)

crypto/err/err.c:687:17: Taking false branch
  685.   
  686.           if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
  687.               || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
                         ^
  688.               ERR_STATE_free(state);
  689.               return NULL;

crypto/err/err.c:693:9: Skipping OPENSSL_init_crypto(): empty list of specs
  691.   
  692.           /* Ignore failures from these */
  693.           OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
                 ^
  694.       }
  695.   

crypto/err/err.c:696:5: 
  694.       }
  695.   
  696. >     return state;
  697.   }
  698.   

crypto/err/err.c:697:1: return from a call to ERR_get_state
  695.   
  696.       return state;
  697. > }
  698.   
  699.   int ERR_get_next_error_library(void)

crypto/err/err.c:477:9: Taking false branch
475.   
476.       es = ERR_get_state();
477.       if (es == NULL)
               ^
478.           return 0;
479.   

crypto/err/err.c:480:9: Taking true branch
478.           return 0;
479.   
480.       if (inc && top) {
               ^
481.           if (file)
482.               *file = "";

crypto/err/err.c:480:16: Taking true branch
478.           return 0;
479.   
480.       if (inc && top) {
                      ^
481.           if (file)
482.               *file = "";

crypto/err/err.c:481:13: Taking false branch
479.   
480.       if (inc && top) {
481.           if (file)
                   ^
482.               *file = "";
483.           if (line)

static unsigned long get_error_values(int inc, int top, const char **file,
                                      int *line, const char **data,
                                      int *flags)
{
    int i = 0;
    ERR_STATE *es;
    unsigned long ret;
    es = ERR_get_state();
    if (es == NULL)
        return 0;
    if (inc && top) {
        if (file)
            *file = "";
        if (line)
            *line = 0;
        if (data)
            *data = "";
        if (flags)
            *flags = 0;
        return ERR_R_INTERNAL_ERROR;
    }
    if (es->bottom == es->top)
        return 0;
    if (top)
        i = es->top;
    else
        i = (es->bottom + 1) % ERR_NUM_ERRORS;
    ret = es->err_buffer[i];
    if (inc) {
        es->bottom = i;
        es->err_buffer[i] = 0;
    }
    if (file != NULL && line != NULL) {
        if (es->err_file[i] == NULL) {
            *file = "NA";
            *line = 0;
        } else {
            *file = es->err_file[i];
            *line = es->err_line[i];
        }
    }
    if (data == NULL) {
        if (inc) {
            err_clear_data(es, i);
        }
    } else {
        if (es->err_data[i] == NULL) {
            *data = "";
            if (flags != NULL)
                *flags = 0;
        } else {
            *data = es->err_data[i];
            if (flags != NULL)
                *flags = es->err_data_flags[i];
        }
    }
    return ret;
}
['static unsigned long get_error_values(int inc, int top, const char **file,\n                                      int *line, const char **data,\n                                      int *flags)\n{\n    int i = 0;\n    ERR_STATE *es;\n    unsigned long ret;\n    es = ERR_get_state();\n    if (es == NULL)\n        return 0;\n    if (inc && top) {\n        if (file)\n            *file = "";\n        if (line)\n            *line = 0;\n        if (data)\n            *data = "";\n        if (flags)\n            *flags = 0;\n        return ERR_R_INTERNAL_ERROR;\n    }\n    if (es->bottom == es->top)\n        return 0;\n    if (top)\n        i = es->top;\n    else\n        i = (es->bottom + 1) % ERR_NUM_ERRORS;\n    ret = es->err_buffer[i];\n    if (inc) {\n        es->bottom = i;\n        es->err_buffer[i] = 0;\n    }\n    if (file != NULL && line != NULL) {\n        if (es->err_file[i] == NULL) {\n            *file = "NA";\n            *line = 0;\n        } else {\n            *file = es->err_file[i];\n            *line = es->err_line[i];\n        }\n    }\n    if (data == NULL) {\n        if (inc) {\n            err_clear_data(es, i);\n        }\n    } else {\n        if (es->err_data[i] == NULL) {\n            *data = "";\n            if (flags != NULL)\n                *flags = 0;\n        } else {\n            *data = es->err_data[i];\n            if (flags != NULL)\n                *flags = es->err_data_flags[i];\n        }\n    }\n    return ret;\n}', '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    if (!OPENSSL_init_crypto(0, NULL))\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    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}', '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}']