crypto/init.c:348: error: MEMORY_LEAK
  memory dynamically allocated by call to `ossl_init_get_thread_local()` at line 330, column 44 is not reachable after line 348, column 9.
Showing all 38 steps of the trace


crypto/init.c:328:1: start of procedure ossl_init_thread_start()
326.   }
327.   
328. > int ossl_init_thread_start(uint64_t opts)
329.   {
330.       struct thread_local_inits_st *locals = ossl_init_get_thread_local(1);

crypto/init.c:330:5: 
328.   int ossl_init_thread_start(uint64_t opts)
329.   {
330. >     struct thread_local_inits_st *locals = ossl_init_get_thread_local(1);
331.   
332.       if (locals == NULL)

crypto/init.c:38:1: start of procedure ossl_init_get_thread_local()
  36.   }
  37.   
  38. > static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
  39.   {
  40.       struct thread_local_inits_st *local =

crypto/init.c:40:5: 
  38.   static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
  39.   {
  40. >     struct thread_local_inits_st *local =
  41.           CRYPTO_THREAD_get_local(&threadstopkey);
  42.   

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/init.c:43:9: Taking true branch
  41.           CRYPTO_THREAD_get_local(&threadstopkey);
  42.   
  43.       if (local == NULL && alloc) {
                ^
  44.           local = OPENSSL_zalloc(sizeof *local);
  45.           CRYPTO_THREAD_set_local(&threadstopkey, local);

crypto/init.c:43:26: Taking true branch
  41.           CRYPTO_THREAD_get_local(&threadstopkey);
  42.   
  43.       if (local == NULL && alloc) {
                                 ^
  44.           local = OPENSSL_zalloc(sizeof *local);
  45.           CRYPTO_THREAD_set_local(&threadstopkey, local);

crypto/init.c:44:9: 
  42.   
  43.       if (local == NULL && alloc) {
  44. >         local = OPENSSL_zalloc(sizeof *local);
  45.           CRYPTO_THREAD_set_local(&threadstopkey, local);
  46.       }

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/init.c:45:9: 
  43.       if (local == NULL && alloc) {
  44.           local = OPENSSL_zalloc(sizeof *local);
  45. >         CRYPTO_THREAD_set_local(&threadstopkey, local);
  46.       }
  47.       if (!alloc) {

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 true 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:87:9: 
    85.   {
    86.       if (pthread_setspecific(*key, val) != 0)
    87. >         return 0;
    88.   
    89.       return 1;

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/init.c:47:10: Taking false branch
  45.           CRYPTO_THREAD_set_local(&threadstopkey, local);
  46.       }
  47.       if (!alloc) {
                 ^
  48.           CRYPTO_THREAD_set_local(&threadstopkey, NULL);
  49.       }

crypto/init.c:51:5: 
  49.       }
  50.   
  51. >     return local;
  52.   }
  53.   

crypto/init.c:52:1: return from a call to ossl_init_get_thread_local
  50.   
  51.       return local;
  52. > }
  53.   
  54.   typedef struct ossl_init_stop_st OPENSSL_INIT_STOP;

crypto/init.c:332:9: Taking false branch
330.       struct thread_local_inits_st *locals = ossl_init_get_thread_local(1);
331.   
332.       if (locals == NULL)
               ^
333.           return 0;
334.   

crypto/init.c:335:9: Taking false branch
333.           return 0;
334.   
335.       if (opts & OPENSSL_INIT_THREAD_ASYNC) {
               ^
336.   #ifdef OPENSSL_INIT_DEBUG
337.           fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "

crypto/init.c:343:9: Taking true branch
341.       }
342.   
343.       if (opts & OPENSSL_INIT_THREAD_ERR_STATE) {
               ^
344.   #ifdef OPENSSL_INIT_DEBUG
345.           fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "

crypto/init.c:348:9: 
346.                           "marking thread for err_state\n");
347.   #endif
348. >         locals->err_state = 1;
349.       }
350.   

int ossl_init_thread_start(uint64_t opts)
{
    struct thread_local_inits_st *locals = ossl_init_get_thread_local(1);
    if (locals == NULL)
        return 0;
    if (opts & OPENSSL_INIT_THREAD_ASYNC) {
#ifdef OPENSSL_INIT_DEBUG
        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "
                        "marking thread for async\n");
#endif
        locals->async = 1;
    }
    if (opts & OPENSSL_INIT_THREAD_ERR_STATE) {
#ifdef OPENSSL_INIT_DEBUG
        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "
                        "marking thread for err_state\n");
#endif
        locals->err_state = 1;
    }
    return 1;
}
['int ossl_init_thread_start(uint64_t opts)\n{\n    struct thread_local_inits_st *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}', 'static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)\n{\n    struct thread_local_inits_st *local =\n        CRYPTO_THREAD_get_local(&threadstopkey);\n    if (local == NULL && alloc) {\n        local = OPENSSL_zalloc(sizeof *local);\n        CRYPTO_THREAD_set_local(&threadstopkey, local);\n    }\n    if (!alloc) {\n        CRYPTO_THREAD_set_local(&threadstopkey, NULL);\n    }\n    return local;\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}']