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


crypto/init.c:363:1: start of procedure ossl_init_thread_start()
361.   }
362.   
363. > int ossl_init_thread_start(uint64_t opts)
364.   {
365.       struct thread_local_inits_st *locals;

crypto/init.c:367:10: Taking false branch
365.       struct thread_local_inits_st *locals;
366.   
367.       if (!OPENSSL_init_crypto(0, NULL))
                ^
368.           return 0;
369.   

crypto/init.c:370:5: 
368.           return 0;
369.   
370. >     locals = ossl_init_get_thread_local(1);
371.   
372.       if (locals == NULL)

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

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

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

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

crypto/init.c:46:9: 
  44.   
  45.       if (local == NULL && alloc) {
  46. >         local = OPENSSL_zalloc(sizeof *local);
  47.           if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
  48.               OPENSSL_free(local);

crypto/mem.c:194:1: start of procedure CRYPTO_zalloc()
    192.   }
    193.   
    194. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    195.   {
    196.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:196:5: 
    194.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    195.   {
    196. >     void *ret = CRYPTO_malloc(num, file, line);
    197.   
    198.       FAILTEST();

crypto/mem.c:166:1: start of procedure CRYPTO_malloc()
      164.   #endif
      165.   
      166. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      167.   {
      168.       void *ret = NULL;

crypto/mem.c:168:5: 
      166.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      167.   {
      168. >     void *ret = NULL;
      169.   
      170.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:170:9: Taking false branch
      168.       void *ret = NULL;
      169.   
      170.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      171.           return malloc_impl(num, file, line);
      172.   

crypto/mem.c:173:9: Taking false branch
      171.           return malloc_impl(num, file, line);
      172.   
      173.       if (num == 0)
                     ^
      174.           return NULL;
      175.   

crypto/mem.c:177:5: 
      175.   
      176.       FAILTEST();
      177. >     allow_customize = 0;
      178.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      179.       if (call_malloc_debug) {

crypto/mem.c:187:5: 
      185.       }
      186.   #else
      187. >     osslargused(file); osslargused(line);
      188.       ret = malloc(num);
      189.   #endif

crypto/mem.c:187:24: 
      185.       }
      186.   #else
      187. >     osslargused(file); osslargused(line);
      188.       ret = malloc(num);
      189.   #endif

crypto/mem.c:188:5: 
      186.   #else
      187.       osslargused(file); osslargused(line);
      188. >     ret = malloc(num);
      189.   #endif
      190.   

crypto/mem.c:191:5: 
      189.   #endif
      190.   
      191. >     return ret;
      192.   }
      193.   

crypto/mem.c:192:1: return from a call to CRYPTO_malloc
      190.   
      191.       return ret;
      192. > }
      193.   
      194.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:199:9: Taking true branch
    197.   
    198.       FAILTEST();
    199.       if (ret != NULL)
                   ^
    200.           memset(ret, 0, num);
    201.       return ret;

crypto/mem.c:200:9: 
    198.       FAILTEST();
    199.       if (ret != NULL)
    200. >         memset(ret, 0, num);
    201.       return ret;
    202.   }

crypto/mem.c:201:5: 
    199.       if (ret != NULL)
    200.           memset(ret, 0, num);
    201. >     return ret;
    202.   }
    203.   

crypto/mem.c:202:1: return from a call to CRYPTO_zalloc
    200.           memset(ret, 0, num);
    201.       return ret;
    202. > }
    203.   
    204.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/init.c:47:13: Taking true branch
  45.       if (local == NULL && alloc) {
  46.           local = OPENSSL_zalloc(sizeof *local);
  47.           if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
                    ^
  48.               OPENSSL_free(local);
  49.               return NULL;

crypto/init.c:47:31: 
  45.       if (local == NULL && alloc) {
  46.           local = OPENSSL_zalloc(sizeof *local);
  47. >         if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
  48.               OPENSSL_free(local);
  49.               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/init.c:47:31: Taking false branch
  45.       if (local == NULL && alloc) {
  46.           local = OPENSSL_zalloc(sizeof *local);
  47.           if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
                                      ^
  48.               OPENSSL_free(local);
  49.               return NULL;

crypto/init.c:52:10: Taking false branch
  50.           }
  51.       }
  52.       if (!alloc) {
                 ^
  53.           CRYPTO_THREAD_set_local(&threadstopkey, NULL);
  54.       }

crypto/init.c:56:5: 
  54.       }
  55.   
  56. >     return local;
  57.   }
  58.   

crypto/init.c:57:1: return from a call to ossl_init_get_thread_local
  55.   
  56.       return local;
  57. > }
  58.   
  59.   typedef struct ossl_init_stop_st OPENSSL_INIT_STOP;

crypto/init.c:372:9: Taking false branch
370.       locals = ossl_init_get_thread_local(1);
371.   
372.       if (locals == NULL)
               ^
373.           return 0;
374.   

crypto/init.c:375:9: Taking false branch
373.           return 0;
374.   
375.       if (opts & OPENSSL_INIT_THREAD_ASYNC) {
               ^
376.   #ifdef OPENSSL_INIT_DEBUG
377.           fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "

crypto/init.c:383:9: Taking true branch
381.       }
382.   
383.       if (opts & OPENSSL_INIT_THREAD_ERR_STATE) {
               ^
384.   #ifdef OPENSSL_INIT_DEBUG
385.           fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "

crypto/init.c:388:9: 
386.                           "marking thread for err_state\n");
387.   #endif
388. >         locals->err_state = 1;
389.       }
390.   

int ossl_init_thread_start(uint64_t opts)
{
    struct thread_local_inits_st *locals;
    if (!OPENSSL_init_crypto(0, NULL))
        return 0;
    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;\n    if (!OPENSSL_init_crypto(0, NULL))\n        return 0;\n    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        if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {\n            OPENSSL_free(local);\n            return NULL;\n        }\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    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}']