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


crypto/err/err.c:434:1: start of procedure get_error_values()
432.   }
433.   
434. > static unsigned long get_error_values(int inc, int top, const char **file,
435.                                         int *line, const char **data,
436.                                         int *flags)

crypto/err/err.c:438:5: 
436.                                         int *flags)
437.   {
438. >     int i = 0;
439.       ERR_STATE *es;
440.       unsigned long ret;

crypto/err/err.c:442:5: 
440.       unsigned long ret;
441.   
442. >     es = ERR_get_state();
443.   
444.       if (inc && top) {

crypto/err/err.c:645:1: start of procedure ERR_get_state()
  643.   }
  644.   
  645. > ERR_STATE *ERR_get_state(void)
  646.   {
  647.       ERR_STATE *state = NULL;

crypto/err/err.c:647:5: 
  645.   ERR_STATE *ERR_get_state(void)
  646.   {
  647. >     ERR_STATE *state = NULL;
  648.   
  649.       if (!RUN_ONCE(&err_init, err_do_init))

crypto/err/err.c:649:10: 
  647.       ERR_STATE *state = NULL;
  648.   
  649. >     if (!RUN_ONCE(&err_init, err_do_init))
  650.           return NULL;
  651.   

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:649:10: Condition is true
  647.       ERR_STATE *state = NULL;
  648.   
  649.       if (!RUN_ONCE(&err_init, err_do_init))
                  ^
  650.           return NULL;
  651.   

crypto/err/err.c:649:10: Taking false branch
  647.       ERR_STATE *state = NULL;
  648.   
  649.       if (!RUN_ONCE(&err_init, err_do_init))
                  ^
  650.           return NULL;
  651.   

crypto/err/err.c:652:5: 
  650.           return NULL;
  651.   
  652. >     state = CRYPTO_THREAD_get_local(&err_thread_local);
  653.   
  654.       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:654:9: Taking true branch
  652.       state = CRYPTO_THREAD_get_local(&err_thread_local);
  653.   
  654.       if (state == NULL) {
                 ^
  655.           state = OPENSSL_zalloc(sizeof(*state));
  656.           if (state == NULL)

crypto/err/err.c:655:9: 
  653.   
  654.       if (state == NULL) {
  655. >         state = OPENSSL_zalloc(sizeof(*state));
  656.           if (state == NULL)
  657.               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:656:13: Taking false branch
  654.       if (state == NULL) {
  655.           state = OPENSSL_zalloc(sizeof(*state));
  656.           if (state == NULL)
                     ^
  657.               return NULL;
  658.   

crypto/err/err.c:659:14: 
  657.               return NULL;
  658.   
  659. >         if (!CRYPTO_THREAD_set_local(&err_thread_local, state)) {
  660.               ERR_STATE_free(state);
  661.               return NULL;

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

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

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

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

crypto/err/err.c:659:14: Taking false branch
  657.               return NULL;
  658.   
  659.           if (!CRYPTO_THREAD_set_local(&err_thread_local, state)) {
                      ^
  660.               ERR_STATE_free(state);
  661.               return NULL;

crypto/err/err.c:665:9: Skipping OPENSSL_init_crypto(): empty list of specs
  663.   
  664.           /* Ignore failures from these */
  665.           OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
                 ^
  666.           ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE);
  667.       }

crypto/err/err.c:666:9: Skipping ossl_init_thread_start(): empty list of specs
  664.           /* Ignore failures from these */
  665.           OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
  666.           ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE);
                 ^
  667.       }
  668.   

crypto/err/err.c:669:5: 
  667.       }
  668.   
  669. >     return state;
  670.   }
  671.   

crypto/err/err.c:670:1: return from a call to ERR_get_state
  668.   
  669.       return state;
  670. > }
  671.   
  672.   int ERR_get_next_error_library(void)

crypto/err/err.c:444:9: Taking true branch
442.       es = ERR_get_state();
443.   
444.       if (inc && top) {
               ^
445.           if (file)
446.               *file = "";

crypto/err/err.c:444:16: Taking true branch
442.       es = ERR_get_state();
443.   
444.       if (inc && top) {
                      ^
445.           if (file)
446.               *file = "";

crypto/err/err.c:445:13: Taking true branch
443.   
444.       if (inc && top) {
445.           if (file)
                   ^
446.               *file = "";
447.           if (line)

crypto/err/err.c:446:13: 
444.       if (inc && top) {
445.           if (file)
446. >             *file = "";
447.           if (line)
448.               *line = 0;

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 (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";
            if (line != NULL)
                *line = 0;
        } else {
            *file = es->err_file[i];
            if (line != NULL)
                *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 (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            if (line != NULL)\n                *line = 0;\n        } else {\n            *file = es->err_file[i];\n            if (line != NULL)\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    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 (!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        ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE);\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 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}']