crypto/async/async.c:414: error: MEMORY_LEAK
  memory dynamically allocated to `return` by call to `CRYPTO_zalloc()` at line 377, column 12 is not reachable after line 414, column 5.
Showing all 58 steps of the trace


crypto/async/async.c:360:1: start of procedure ASYNC_init_thread()
358.   }
359.   
360. > int ASYNC_init_thread(size_t max_size, size_t init_size)
361.   {
362.       async_pool *pool;

crypto/async/async.c:363:5: 
361.   {
362.       async_pool *pool;
363. >     size_t curr_size = 0;
364.   
365.       if (init_size > max_size) {

crypto/async/async.c:365:9: Taking false branch
363.       size_t curr_size = 0;
364.   
365.       if (init_size > max_size) {
               ^
366.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);
367.           return 0;

crypto/async/async.c:370:10: Taking false branch
368.       }
369.   
370.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {
                ^
371.           return 0;
372.       }

crypto/async/async.c:373:10: Taking false branch
371.           return 0;
372.       }
373.       if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {
                ^
374.           return 0;
375.       }

crypto/async/async.c:377:5: 
375.       }
376.   
377. >     pool = OPENSSL_zalloc(sizeof *pool);
378.       if (pool == NULL) {
379.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);

crypto/mem.c:146:1: start of procedure CRYPTO_zalloc()
  144.   }
  145.   
  146. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  147.   {
  148.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:148:5: 
  146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  147.   {
  148. >     void *ret = CRYPTO_malloc(num, file, line);
  149.   
  150.       if (ret != NULL)

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
    117.   }
    118.   
    119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121.       void *ret = NULL;

crypto/mem.c:121:5: 
    119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121. >     void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
    121.       void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    124.           return malloc_impl(num, file, line);
    125.   

crypto/mem.c:126:9: Taking false branch
    124.           return malloc_impl(num, file, line);
    125.   
    126.       if (num <= 0)
                   ^
    127.           return NULL;
    128.   

crypto/mem.c:129:5: 
    127.           return NULL;
    128.   
    129. >     allow_customize = 0;
    130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
    137.       }
    138.   #else
    139. >     osslargused(file); osslargused(line);
    140.       ret = malloc(num);
    141.   #endif

crypto/mem.c:139:24: 
    137.       }
    138.   #else
    139. >     osslargused(file); osslargused(line);
    140.       ret = malloc(num);
    141.   #endif

crypto/mem.c:140:5: 
    138.   #else
    139.       osslargused(file); osslargused(line);
    140. >     ret = malloc(num);
    141.   #endif
    142.   

crypto/mem.c:143:5: 
    141.   #endif
    142.   
    143. >     return ret;
    144.   }
    145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
    142.   
    143.       return ret;
    144. > }
    145.   
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:150:9: Taking true branch
  148.       void *ret = CRYPTO_malloc(num, file, line);
  149.   
  150.       if (ret != NULL)
                 ^
  151.           memset(ret, 0, num);
  152.       return ret;

crypto/mem.c:151:9: 
  149.   
  150.       if (ret != NULL)
  151. >         memset(ret, 0, num);
  152.       return ret;
  153.   }

crypto/mem.c:152:5: 
  150.       if (ret != NULL)
  151.           memset(ret, 0, num);
  152. >     return ret;
  153.   }
  154.   

crypto/mem.c:153:1: return from a call to CRYPTO_zalloc
  151.           memset(ret, 0, num);
  152.       return ret;
  153. > }
  154.   
  155.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/async/async.c:378:9: Taking false branch
376.   
377.       pool = OPENSSL_zalloc(sizeof *pool);
378.       if (pool == NULL) {
               ^
379.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
380.           return 0;

crypto/async/async.c:383:5: 
381.       }
382.   
383. >     pool->jobs = sk_ASYNC_JOB_new_null();
384.       if (pool->jobs == NULL) {
385.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);

crypto/async/async_locl.h:103:1: start of procedure sk_ASYNC_JOB_new_null()
  101.   };
  102.   
  103. > DEFINE_STACK_OF(ASYNC_JOB)
  104.   
  105.   struct async_pool_st {

crypto/stack/stack.c:144:1: start of procedure sk_new_null()
    142.   }
    143.   
    144. > _STACK *sk_new_null(void)
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);

crypto/stack/stack.c:146:5: Skipping sk_new(): empty list of specs
    144.   _STACK *sk_new_null(void)
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);
               ^
    147.   }
    148.   

crypto/stack/stack.c:147:1: return from a call to sk_new_null
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);
    147. > }
    148.   
    149.   _STACK *sk_new(int (*c) (const void *, const void *))

crypto/async/async_locl.h:103:1: return from a call to sk_ASYNC_JOB_new_null
  101.   };
  102.   
  103. > DEFINE_STACK_OF(ASYNC_JOB)
  104.   
  105.   struct async_pool_st {

crypto/async/async.c:384:9: Taking false branch
382.   
383.       pool->jobs = sk_ASYNC_JOB_new_null();
384.       if (pool->jobs == NULL) {
               ^
385.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
386.           OPENSSL_free(pool);

crypto/async/async.c:390:5: 
388.       }
389.   
390. >     pool->max_size = max_size;
391.   
392.       /* Pre-create jobs as required */

crypto/async/async.c:393:12: Loop condition is true. Entering loop body
391.   
392.       /* Pre-create jobs as required */
393.       while (init_size--) {
                  ^
394.           ASYNC_JOB *job;
395.           job = async_job_new();

crypto/async/async.c:395:9: Skipping async_job_new(): empty list of specs
393.       while (init_size--) {
394.           ASYNC_JOB *job;
395.           job = async_job_new();
               ^
396.           if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
397.               /*

crypto/async/async.c:396:13: Taking false branch
394.           ASYNC_JOB *job;
395.           job = async_job_new();
396.           if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
                   ^
397.               /*
398.                * Not actually fatal because we already created the pool, just

crypto/async/async.c:396:29: 
394.           ASYNC_JOB *job;
395.           job = async_job_new();
396. >         if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
397.               /*
398.                * Not actually fatal because we already created the pool, just

crypto/async/arch/async_posix.c:68:1: start of procedure async_fibre_makecontext()
  66.   
  67.   
  68. > int async_fibre_makecontext(async_fibre *fibre)
  69.   {
  70.       fibre->env_init = 0;

crypto/async/arch/async_posix.c:70:5: 
  68.   int async_fibre_makecontext(async_fibre *fibre)
  69.   {
  70. >     fibre->env_init = 0;
  71.       if (getcontext(&fibre->fibre) == 0) {
  72.           fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE);

crypto/async/arch/async_posix.c:71:9: Taking true branch
  69.   {
  70.       fibre->env_init = 0;
  71.       if (getcontext(&fibre->fibre) == 0) {
                ^
  72.           fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE);
  73.           if (fibre->fibre.uc_stack.ss_sp != NULL) {

crypto/async/arch/async_posix.c:72:9: 
  70.       fibre->env_init = 0;
  71.       if (getcontext(&fibre->fibre) == 0) {
  72. >         fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE);
  73.           if (fibre->fibre.uc_stack.ss_sp != NULL) {
  74.               fibre->fibre.uc_stack.ss_size = STACKSIZE;

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
    117.   }
    118.   
    119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121.       void *ret = NULL;

crypto/mem.c:121:5: 
    119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121. >     void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking true branch
    121.       void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    124.           return malloc_impl(num, file, line);
    125.   

crypto/mem.c:123:32: Taking true branch
    121.       void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                          ^
    124.           return malloc_impl(num, file, line);
    125.   

crypto/mem.c:124:9: Skipping __function_pointer__(): unresolved function pointer
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
    124.           return malloc_impl(num, file, line);
                   ^
    125.   
    126.       if (num <= 0)

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
    142.   
    143.       return ret;
    144. > }
    145.   
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/async/arch/async_posix.c:73:13: Taking false branch
  71.       if (getcontext(&fibre->fibre) == 0) {
  72.           fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE);
  73.           if (fibre->fibre.uc_stack.ss_sp != NULL) {
                    ^
  74.               fibre->fibre.uc_stack.ss_size = STACKSIZE;
  75.               fibre->fibre.uc_link = NULL;

crypto/async/arch/async_posix.c:82:5: 
  80.           fibre->fibre.uc_stack.ss_sp = NULL;
  81.       }
  82. >     return 0;
  83.   }
  84.   

crypto/async/arch/async_posix.c:83:1: return from a call to async_fibre_makecontext
  81.       }
  82.       return 0;
  83. > }
  84.   
  85.   void async_fibre_free(async_fibre *fibre)

crypto/async/async.c:396:29: Taking true branch
394.           ASYNC_JOB *job;
395.           job = async_job_new();
396.           if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
                                   ^
397.               /*
398.                * Not actually fatal because we already created the pool, just

crypto/async/async.c:401:13: Skipping async_job_free(): empty list of specs
399.                * skip creation of any more jobs
400.                */
401.               async_job_free(job);
                   ^
402.               break;
403.           }

crypto/async/async.c:408:5: 
406.           curr_size++;
407.       }
408. >     pool->curr_size = curr_size;
409.       if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {
410.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);

crypto/async/async.c:409:10: 
407.       }
408.       pool->curr_size = curr_size;
409. >     if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {
410.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);
411.           goto err;

crypto/threads_pthread.c:123:1: start of procedure CRYPTO_THREAD_set_local()
  121.   }
  122.   
  123. > int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
  124.   {
  125.       if (pthread_setspecific(*key, val) != 0)

crypto/threads_pthread.c:125:9: Taking false branch
  123.   int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
  124.   {
  125.       if (pthread_setspecific(*key, val) != 0)
                 ^
  126.           return 0;
  127.   

crypto/threads_pthread.c:128:5: 
  126.           return 0;
  127.   
  128. >     return 1;
  129.   }
  130.   

crypto/threads_pthread.c:129:1: return from a call to CRYPTO_THREAD_set_local
  127.   
  128.       return 1;
  129. > }
  130.   
  131.   int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)

crypto/async/async.c:409:10: Taking false branch
407.       }
408.       pool->curr_size = curr_size;
409.       if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {
                ^
410.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);
411.           goto err;

crypto/async/async.c:414:5: 
412.       }
413.   
414. >     return 1;
415.   err:
416.       async_free_pool_internal(pool);

int ASYNC_init_thread(size_t max_size, size_t init_size)
{
    async_pool *pool;
    size_t curr_size = 0;
    if (init_size > max_size) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);
        return 0;
    }
    if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {
        return 0;
    }
    if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {
        return 0;
    }
    pool = OPENSSL_zalloc(sizeof *pool);
    if (pool == NULL) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
        return 0;
    }
    pool->jobs = sk_ASYNC_JOB_new_null();
    if (pool->jobs == NULL) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
        OPENSSL_free(pool);
        return 0;
    }
    pool->max_size = max_size;
    while (init_size--) {
        ASYNC_JOB *job;
        job = async_job_new();
        if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
            async_job_free(job);
            break;
        }
        job->funcargs = NULL;
        sk_ASYNC_JOB_push(pool->jobs, job);
        curr_size++;
    }
    pool->curr_size = curr_size;
    if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);
        goto err;
    }
    return 1;
err:
    async_free_pool_internal(pool);
    return 0;
}
['int ASYNC_init_thread(size_t max_size, size_t init_size)\n{\n    async_pool *pool;\n    size_t curr_size = 0;\n    if (init_size > max_size) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);\n        return 0;\n    }\n    if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {\n        return 0;\n    }\n    if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {\n        return 0;\n    }\n    pool = OPENSSL_zalloc(sizeof *pool);\n    if (pool == NULL) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    pool->jobs = sk_ASYNC_JOB_new_null();\n    if (pool->jobs == NULL) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(pool);\n        return 0;\n    }\n    pool->max_size = max_size;\n    while (init_size--) {\n        ASYNC_JOB *job;\n        job = async_job_new();\n        if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {\n            async_job_free(job);\n            break;\n        }\n        job->funcargs = NULL;\n        sk_ASYNC_JOB_push(pool->jobs, job);\n        curr_size++;\n    }\n    pool->curr_size = curr_size;\n    if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);\n        goto err;\n    }\n    return 1;\nerr:\n    async_free_pool_internal(pool);\n    return 0;\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}', '_STACK *sk_new_null(void)\n{\n    return sk_new((int (*)(const void *, const void *))0);\n}', 'int async_fibre_makecontext(async_fibre *fibre)\n{\n    fibre->env_init = 0;\n    if (getcontext(&fibre->fibre) == 0) {\n        fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE);\n        if (fibre->fibre.uc_stack.ss_sp != NULL) {\n            fibre->fibre.uc_stack.ss_size = STACKSIZE;\n            fibre->fibre.uc_link = NULL;\n            makecontext(&fibre->fibre, async_start_func, 0);\n            return 1;\n        }\n    } else {\n        fibre->fibre.uc_stack.ss_sp = NULL;\n    }\n    return 0;\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}']