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


crypto/async/async.c:355:1: start of procedure ASYNC_init_thread()
353.   }
354.   
355. > int ASYNC_init_thread(size_t max_size, size_t init_size)
356.   {
357.       async_pool *pool;

crypto/async/async.c:358:5: 
356.   {
357.       async_pool *pool;
358. >     size_t curr_size = 0;
359.   
360.       if (init_size > max_size) {

crypto/async/async.c:360:9: Taking false branch
358.       size_t curr_size = 0;
359.   
360.       if (init_size > max_size) {
               ^
361.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);
362.           return 0;

crypto/async/async.c:365:10: Taking false branch
363.       }
364.   
365.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {
                ^
366.           return 0;
367.       }

crypto/async/async.c:368:10: Taking false branch
366.           return 0;
367.       }
368.       if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {
                ^
369.           return 0;
370.       }

crypto/async/async.c:372:5: 
370.       }
371.   
372. >     pool = OPENSSL_zalloc(sizeof *pool);
373.       if (pool == NULL) {
374.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);

crypto/mem.c:158:1: start of procedure CRYPTO_zalloc()
  156.   }
  157.   
  158. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  159.   {
  160.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:160:5: 
  158.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  159.   {
  160. >     void *ret = CRYPTO_malloc(num, file, line);
  161.   
  162.       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:155:5: 
    153.   #endif
    154.   
    155. >     return ret;
    156.   }
    157.   

crypto/mem.c:156:1: return from a call to CRYPTO_malloc
    154.   
    155.       return ret;
    156. > }
    157.   
    158.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:162:9: Taking true branch
  160.       void *ret = CRYPTO_malloc(num, file, line);
  161.   
  162.       if (ret != NULL)
                 ^
  163.           memset(ret, 0, num);
  164.       return ret;

crypto/mem.c:163:9: 
  161.   
  162.       if (ret != NULL)
  163. >         memset(ret, 0, num);
  164.       return ret;
  165.   }

crypto/mem.c:164:5: 
  162.       if (ret != NULL)
  163.           memset(ret, 0, num);
  164. >     return ret;
  165.   }
  166.   

crypto/mem.c:165:1: return from a call to CRYPTO_zalloc
  163.           memset(ret, 0, num);
  164.       return ret;
  165. > }
  166.   
  167.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/async/async.c:373:9: Taking false branch
371.   
372.       pool = OPENSSL_zalloc(sizeof *pool);
373.       if (pool == NULL) {
               ^
374.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
375.           return 0;

crypto/async/async.c:378:5: 
376.       }
377.   
378. >     pool->jobs = sk_ASYNC_JOB_new_null();
379.       if (pool->jobs == NULL) {
380.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);

crypto/async/async_locl.h:89:1: start of procedure sk_ASYNC_JOB_new_null()
  87.   };
  88.   
  89. > DEFINE_STACK_OF(ASYNC_JOB)
  90.   
  91.   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:89:1: return from a call to sk_ASYNC_JOB_new_null
  87.   };
  88.   
  89. > DEFINE_STACK_OF(ASYNC_JOB)
  90.   
  91.   struct async_pool_st {

crypto/async/async.c:379:9: Taking false branch
377.   
378.       pool->jobs = sk_ASYNC_JOB_new_null();
379.       if (pool->jobs == NULL) {
               ^
380.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
381.           OPENSSL_free(pool);

crypto/async/async.c:385:5: 
383.       }
384.   
385. >     pool->max_size = max_size;
386.   
387.       /* Pre-create jobs as required */

crypto/async/async.c:388:12: Loop condition is true. Entering loop body
386.   
387.       /* Pre-create jobs as required */
388.       while (init_size--) {
                  ^
389.           ASYNC_JOB *job;
390.           job = async_job_new();

crypto/async/async.c:390:9: Skipping async_job_new(): empty list of specs
388.       while (init_size--) {
389.           ASYNC_JOB *job;
390.           job = async_job_new();
               ^
391.           if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
392.               /*

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

crypto/async/async.c:391:29: 
389.           ASYNC_JOB *job;
390.           job = async_job_new();
391. >         if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
392.               /*
393.                * 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:391:29: Taking true branch
389.           ASYNC_JOB *job;
390.           job = async_job_new();
391.           if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
                                   ^
392.               /*
393.                * Not actually fatal because we already created the pool, just

crypto/async/async.c:396:13: Skipping async_job_free(): empty list of specs
394.                * skip creation of any more jobs
395.                */
396.               async_job_free(job);
                   ^
397.               break;
398.           }

crypto/async/async.c:403:5: 
401.           curr_size++;
402.       }
403. >     pool->curr_size = curr_size;
404.       if (!async_set_pool(pool)) {
405.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);

crypto/async/async.c:404:10: Taking false branch
402.       }
403.       pool->curr_size = curr_size;
404.       if (!async_set_pool(pool)) {
                ^
405.           ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);
406.           goto err;

crypto/async/async.c:409:5: 
407.       }
408.   
409. >     return 1;
410.   err:
411.       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#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\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}']