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


crypto/err/err.c:451:1: start of procedure get_error_values()
449.   }
450.   
451. > static unsigned long get_error_values(int inc, int top, const char **file,
452.                                         int *line, const char **data,
453.                                         int *flags)

crypto/err/err.c:455:5: 
453.                                         int *flags)
454.   {
455. >     int i = 0;
456.       ERR_STATE *es;
457.       unsigned long ret;

crypto/err/err.c:459:5: 
457.       unsigned long ret;
458.   
459. >     es = ERR_get_state();
460.   
461.       if (inc && top) {

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:63:1: start of procedure CRYPTO_THREAD_run_once()
    61.   }
    62.   
    63. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    64.   {
    65.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:65:9: Taking false branch
    63.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    64.   {
    65.       if (pthread_once(once, init) != 0)
                  ^
    66.           return 0;
    67.   

crypto/threads_pthread.c:68:5: 
    66.           return 0;
    67.   
    68. >     return 1;
    69.   }
    70.   

crypto/threads_pthread.c:69:1: return from a call to CRYPTO_THREAD_run_once
    67.   
    68.       return 1;
    69. > }
    70.   
    71.   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:671:5: 
  669.           return NULL;
  670.   
  671. >     state = CRYPTO_THREAD_get_local(&err_thread_local);
  672.   
  673.       if (state == NULL) {

crypto/threads_pthread.c:79:1: start of procedure CRYPTO_THREAD_get_local()
    77.   }
    78.   
    79. > void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
    80.   {
    81.       return pthread_getspecific(*key);

crypto/threads_pthread.c:81:5: Skipping pthread_getspecific(): method has no implementation
    79.   void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
    80.   {
    81.       return pthread_getspecific(*key);
              ^
    82.   }
    83.   

crypto/threads_pthread.c:82:1: return from a call to CRYPTO_THREAD_get_local
    80.   {
    81.       return pthread_getspecific(*key);
    82. > }
    83.   
    84.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)

crypto/err/err.c:673:9: Taking true branch
  671.       state = CRYPTO_THREAD_get_local(&err_thread_local);
  672.   
  673.       if (state == NULL) {
                 ^
  674.           state = OPENSSL_zalloc(sizeof(*state));
  675.           if (state == NULL)

crypto/err/err.c:674:9: 
  672.   
  673.       if (state == NULL) {
  674. >         state = OPENSSL_zalloc(sizeof(*state));
  675.           if (state == NULL)
  676.               return NULL;

crypto/mem.c:98:1: start of procedure CRYPTO_zalloc()
    96.   }
    97.   
    98. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:100:5: 
    98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100. >     void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
      69.   }
      70.   
      71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73.       void *ret = NULL;

crypto/mem.c:73:5: 
      71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73. >     void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
      73.       void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                    ^
      76.           return malloc_impl(num, file, line);
      77.   

crypto/mem.c:78:9: Taking false branch
      76.           return malloc_impl(num, file, line);
      77.   
      78.       if (num <= 0)
                    ^
      79.           return NULL;
      80.   

crypto/mem.c:81:5: 
      79.           return NULL;
      80.   
      81. >     allow_customize = 0;
      82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:91:24: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:92:5: 
      90.   #else
      91.       osslargused(file); osslargused(line);
      92. >     ret = malloc(num);
      93.   #endif
      94.   

crypto/mem.c:95:5: 
      93.   #endif
      94.   
      95. >     return ret;
      96.   }
      97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
      94.   
      95.       return ret;
      96. > }
      97.   
      98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:102:9: Taking true branch
    100.       void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)
                   ^
    103.           memset(ret, 0, num);
    104.       return ret;

crypto/mem.c:103:9: 
    101.   
    102.       if (ret != NULL)
    103. >         memset(ret, 0, num);
    104.       return ret;
    105.   }

crypto/mem.c:104:5: 
    102.       if (ret != NULL)
    103.           memset(ret, 0, num);
    104. >     return ret;
    105.   }
    106.   

crypto/mem.c:105:1: return from a call to CRYPTO_zalloc
    103.           memset(ret, 0, num);
    104.       return ret;
    105. > }
    106.   
    107.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/err/err.c:675:13: Taking false branch
  673.       if (state == NULL) {
  674.           state = OPENSSL_zalloc(sizeof(*state));
  675.           if (state == NULL)
                     ^
  676.               return NULL;
  677.   

crypto/err/err.c:678:14: 
  676.               return NULL;
  677.   
  678. >         if (!CRYPTO_THREAD_set_local(&err_thread_local, state)) {
  679.               ERR_STATE_free(state);
  680.               return NULL;

crypto/threads_pthread.c:84:1: start of procedure CRYPTO_THREAD_set_local()
    82.   }
    83.   
    84. > int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
    85.   {
    86.       if (pthread_setspecific(*key, val) != 0)

crypto/threads_pthread.c:86:9: Taking false branch
    84.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
    85.   {
    86.       if (pthread_setspecific(*key, val) != 0)
                  ^
    87.           return 0;
    88.   

crypto/threads_pthread.c:89:5: 
    87.           return 0;
    88.   
    89. >     return 1;
    90.   }
    91.   

crypto/threads_pthread.c:90:1: return from a call to CRYPTO_THREAD_set_local
    88.   
    89.       return 1;
    90. > }
    91.   
    92.   int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)

crypto/err/err.c:678:14: Taking false branch
  676.               return NULL;
  677.   
  678.           if (!CRYPTO_THREAD_set_local(&err_thread_local, state)) {
                      ^
  679.               ERR_STATE_free(state);
  680.               return NULL;

crypto/err/err.c:684:9: Skipping OPENSSL_init_crypto(): empty list of specs
  682.   
  683.           /* Ignore failures from these */
  684.           OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
                 ^
  685.           ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE);
  686.       }

crypto/err/err.c:685:9: Skipping ossl_init_thread_start(): empty list of specs
  683.           /* Ignore failures from these */
  684.           OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
  685.           ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE);
                 ^
  686.       }
  687.   

crypto/err/err.c:688:5: 
  686.       }
  687.   
  688. >     return state;
  689.   }
  690.   

crypto/err/err.c:689:1: return from a call to ERR_get_state
  687.   
  688.       return state;
  689. > }
  690.   
  691.   int ERR_get_next_error_library(void)

crypto/err/err.c:461:9: Taking true branch
459.       es = ERR_get_state();
460.   
461.       if (inc && top) {
               ^
462.           if (file)
463.               *file = "";

crypto/err/err.c:461:16: Taking true branch
459.       es = ERR_get_state();
460.   
461.       if (inc && top) {
                      ^
462.           if (file)
463.               *file = "";

crypto/err/err.c:462:13: Taking true branch
460.   
461.       if (inc && top) {
462.           if (file)
                   ^
463.               *file = "";
464.           if (line)

crypto/err/err.c:463:13: 
461.       if (inc && top) {
462.           if (file)
463. >             *file = "";
464.           if (line)
465.               *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    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    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}']