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


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

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

crypto/init.c:383:5: 
381.           return 0;
382.   
383. >     locals = ossl_init_get_thread_local(1);
384.   
385.       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:221:1: start of procedure CRYPTO_zalloc()
    219.   }
    220.   
    221. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    222.   {
    223.       void *ret = CRYPTO_malloc(num, file, line);

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

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

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

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

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

crypto/mem.c:204:5: 
      202.   
      203.       FAILTEST();
      204. >     allow_customize = 0;
      205.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      206.       if (call_malloc_debug) {

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

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

crypto/mem.c:215:5: 
      213.   #else
      214.       (void)(file); (void)(line);
      215. >     ret = malloc(num);
      216.   #endif
      217.   

crypto/mem.c:218:5: 
      216.   #endif
      217.   
      218. >     return ret;
      219.   }
      220.   

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

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

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

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

crypto/mem.c:229:1: return from a call to CRYPTO_zalloc
    227.           memset(ret, 0, num);
    228.       return ret;
    229. > }
    230.   
    231.   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:385:9: Taking false branch
383.       locals = ossl_init_get_thread_local(1);
384.   
385.       if (locals == NULL)
               ^
386.           return 0;
387.   

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

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

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