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


crypto/init.c:377:1: start of procedure ossl_init_thread_start()
375.   }
376.   
377. > int ossl_init_thread_start(uint64_t opts)
378.   {
379.       struct thread_local_inits_st *locals;

crypto/init.c:381:10: Taking false branch
379.       struct thread_local_inits_st *locals;
380.   
381.       if (!OPENSSL_init_crypto(0, NULL))
                ^
382.           return 0;
383.   

crypto/init.c:384:5: 
382.           return 0;
383.   
384. >     locals = ossl_init_get_thread_local(1);
385.   
386.       if (locals == NULL)

crypto/init.c:50:1: start of procedure ossl_init_get_thread_local()
  48.   }
  49.   
  50. > static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
  51.   {
  52.       struct thread_local_inits_st *local =

crypto/init.c:52:5: 
  50.   static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
  51.   {
  52. >     struct thread_local_inits_st *local =
  53.           CRYPTO_THREAD_get_local(&threadstopkey);
  54.   

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/init.c:55:9: Taking true branch
  53.           CRYPTO_THREAD_get_local(&threadstopkey);
  54.   
  55.       if (local == NULL && alloc) {
                ^
  56.           local = OPENSSL_zalloc(sizeof(*local));
  57.           if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {

crypto/init.c:55:26: Taking true branch
  53.           CRYPTO_THREAD_get_local(&threadstopkey);
  54.   
  55.       if (local == NULL && alloc) {
                                 ^
  56.           local = OPENSSL_zalloc(sizeof(*local));
  57.           if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {

crypto/init.c:56:9: 
  54.   
  55.       if (local == NULL && alloc) {
  56. >         local = OPENSSL_zalloc(sizeof(*local));
  57.           if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
  58.               OPENSSL_free(local);

crypto/mem.c:218:1: start of procedure CRYPTO_zalloc()
    216.   }
    217.   
    218. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    219.   {
    220.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:220:5: 
    218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    219.   {
    220. >     void *ret = CRYPTO_malloc(num, file, line);
    221.   
    222.       FAILTEST();

crypto/mem.c:189:1: start of procedure CRYPTO_malloc()
      187.   #endif
      188.   
      189. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      190.   {
      191.       void *ret = NULL;

crypto/mem.c:191:5: 
      189.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      190.   {
      191. >     void *ret = NULL;
      192.   
      193.       INCREMENT(malloc_count);

crypto/mem.c:194:9: Taking false branch
      192.   
      193.       INCREMENT(malloc_count);
      194.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      195.           return malloc_impl(num, file, line);
      196.   

crypto/mem.c:197:9: Taking false branch
      195.           return malloc_impl(num, file, line);
      196.   
      197.       if (num == 0)
                     ^
      198.           return NULL;
      199.   

crypto/mem.c:201:5: 
      199.   
      200.       FAILTEST();
      201. >     allow_customize = 0;
      202.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      203.       if (call_malloc_debug) {

crypto/mem.c:211:5: 
      209.       }
      210.   #else
      211. >     (void)(file); (void)(line);
      212.       ret = malloc(num);
      213.   #endif

crypto/mem.c:211:19: 
      209.       }
      210.   #else
      211. >     (void)(file); (void)(line);
      212.       ret = malloc(num);
      213.   #endif

crypto/mem.c:212:5: 
      210.   #else
      211.       (void)(file); (void)(line);
      212. >     ret = malloc(num);
      213.   #endif
      214.   

crypto/mem.c:215:5: 
      213.   #endif
      214.   
      215. >     return ret;
      216.   }
      217.   

crypto/mem.c:216:1: return from a call to CRYPTO_malloc
      214.   
      215.       return ret;
      216. > }
      217.   
      218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:223:9: Taking true branch
    221.   
    222.       FAILTEST();
    223.       if (ret != NULL)
                   ^
    224.           memset(ret, 0, num);
    225.       return ret;

crypto/mem.c:224:9: 
    222.       FAILTEST();
    223.       if (ret != NULL)
    224. >         memset(ret, 0, num);
    225.       return ret;
    226.   }

crypto/mem.c:225:5: 
    223.       if (ret != NULL)
    224.           memset(ret, 0, num);
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_zalloc
    224.           memset(ret, 0, num);
    225.       return ret;
    226. > }
    227.   
    228.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/init.c:57:13: Taking true branch
  55.       if (local == NULL && alloc) {
  56.           local = OPENSSL_zalloc(sizeof(*local));
  57.           if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
                    ^
  58.               OPENSSL_free(local);
  59.               return NULL;

crypto/init.c:57:31: 
  55.       if (local == NULL && alloc) {
  56.           local = OPENSSL_zalloc(sizeof(*local));
  57. >         if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
  58.               OPENSSL_free(local);
  59.               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/init.c:57:31: Taking false branch
  55.       if (local == NULL && alloc) {
  56.           local = OPENSSL_zalloc(sizeof(*local));
  57.           if (local != NULL && !CRYPTO_THREAD_set_local(&threadstopkey, local)) {
                                      ^
  58.               OPENSSL_free(local);
  59.               return NULL;

crypto/init.c:62:10: Taking false branch
  60.           }
  61.       }
  62.       if (!alloc) {
                 ^
  63.           CRYPTO_THREAD_set_local(&threadstopkey, NULL);
  64.       }

crypto/init.c:66:5: 
  64.       }
  65.   
  66. >     return local;
  67.   }
  68.   

crypto/init.c:67:1: return from a call to ossl_init_get_thread_local
  65.   
  66.       return local;
  67. > }
  68.   
  69.   typedef struct ossl_init_stop_st OPENSSL_INIT_STOP;

crypto/init.c:386:9: Taking false branch
384.       locals = ossl_init_get_thread_local(1);
385.   
386.       if (locals == NULL)
               ^
387.           return 0;
388.   

crypto/init.c:389:9: Taking false branch
387.           return 0;
388.   
389.       if (opts & OPENSSL_INIT_THREAD_ASYNC) {
               ^
390.   #ifdef OPENSSL_INIT_DEBUG
391.           fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "

crypto/init.c:397:9: Taking true branch
395.       }
396.   
397.       if (opts & OPENSSL_INIT_THREAD_ERR_STATE) {
               ^
398.   #ifdef OPENSSL_INIT_DEBUG
399.           fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "

crypto/init.c:402:9: 
400.                           "marking thread for err_state\n");
401.   #endif
402. >         locals->err_state = 1;
403.       }
404.   

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    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    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    (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}']