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


crypto/async/async.c:344:1: start of procedure ASYNC_init_thread()
342.   }
343.   
344. > int ASYNC_init_thread(size_t max_size, size_t init_size)
345.   {
346.       async_pool *pool;

crypto/async/async.c:347:5: 
345.   {
346.       async_pool *pool;
347. >     size_t curr_size = 0;
348.   
349.       if (init_size > max_size) {

crypto/async/async.c:349:9: Taking false branch
347.       size_t curr_size = 0;
348.   
349.       if (init_size > max_size) {
               ^
350.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);
351.           return 0;

crypto/async/async.c:354:10: Taking false branch
352.       }
353.   
354.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {
                ^
355.           return 0;
356.       }

crypto/async/async.c:357:10: Taking false branch
355.           return 0;
356.       }
357.       if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {
                ^
358.           return 0;
359.       }

crypto/async/async.c:361:5: 
359.       }
360.   
361. >     pool = OPENSSL_zalloc(sizeof *pool);
362.       if (pool == NULL) {
363.           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:362:9: Taking false branch
360.   
361.       pool = OPENSSL_zalloc(sizeof *pool);
362.       if (pool == NULL) {
               ^
363.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
364.           return 0;

crypto/async/async.c:367:5: 
365.       }
366.   
367. >     pool->jobs = sk_ASYNC_JOB_new_null();
368.       if (pool->jobs == NULL) {
369.           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:368:9: Taking false branch
366.   
367.       pool->jobs = sk_ASYNC_JOB_new_null();
368.       if (pool->jobs == NULL) {
               ^
369.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
370.           OPENSSL_free(pool);

crypto/async/async.c:374:5: 
372.       }
373.   
374. >     pool->max_size = max_size;
375.   
376.       /* Pre-create jobs as required */

crypto/async/async.c:377:12: Loop condition is true. Entering loop body
375.   
376.       /* Pre-create jobs as required */
377.       while (init_size--) {
                  ^
378.           ASYNC_JOB *job;
379.           job = async_job_new();

crypto/async/async.c:379:9: Skipping async_job_new(): empty list of specs
377.       while (init_size--) {
378.           ASYNC_JOB *job;
379.           job = async_job_new();
               ^
380.           if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
381.               /*

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

crypto/async/async.c:380:29: 
378.           ASYNC_JOB *job;
379.           job = async_job_new();
380. >         if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
381.               /*
382.                * Not actually fatal because we already created the pool, just

crypto/async/arch/async_posix.c:83:1: start of procedure async_fibre_makecontext()
  81.   }
  82.   
  83. > int async_fibre_makecontext(async_fibre *fibre)
  84.   {
  85.       fibre->env_init = 0;

crypto/async/arch/async_posix.c:85:5: 
  83.   int async_fibre_makecontext(async_fibre *fibre)
  84.   {
  85. >     fibre->env_init = 0;
  86.       if (getcontext(&fibre->fibre) == 0) {
  87.           fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE);

crypto/async/arch/async_posix.c:86:9: Taking false branch
  84.   {
  85.       fibre->env_init = 0;
  86.       if (getcontext(&fibre->fibre) == 0) {
                ^
  87.           fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE);
  88.           if (fibre->fibre.uc_stack.ss_sp != NULL) {

crypto/async/arch/async_posix.c:95:9: 
  93.           }
  94.       } else {
  95. >         fibre->fibre.uc_stack.ss_sp = NULL;
  96.       }
  97.       return 0;

crypto/async/arch/async_posix.c:97:5: 
  95.           fibre->fibre.uc_stack.ss_sp = NULL;
  96.       }
  97. >     return 0;
  98.   }
  99.   

crypto/async/arch/async_posix.c:98:1: return from a call to async_fibre_makecontext
  96.       }
  97.       return 0;
  98. > }
  99.   
  100.   void async_fibre_free(async_fibre *fibre)

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

crypto/async/async.c:385:13: Skipping async_job_free(): empty list of specs
383.                * skip creation of any more jobs
384.                */
385.               async_job_free(job);
                   ^
386.               break;
387.           }

crypto/async/async.c:392:5: 
390.           curr_size++;
391.       }
392. >     pool->curr_size = curr_size;
393.       if (!async_set_pool(pool)) {
394.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);

crypto/async/async.c:393:10: Taking false branch
391.       }
392.       pool->curr_size = curr_size;
393.       if (!async_set_pool(pool)) {
                ^
394.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);
395.           goto err;

crypto/async/async.c:398:5: 
396.       }
397.   
398. >     return 1;
399.   err:
400.       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 (!async_set_pool(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 (!async_set_pool(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}']