crypto/async/async.c:282: error: MEMORY_LEAK
  memory dynamically allocated by call to `async_ctx_new()` at line 226, column 15 is not reachable after line 282, column 17.
Showing all 69 steps of the trace


crypto/async/async.c:221:1: start of procedure ASYNC_start_job()
219.   }
220.   
221. > int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),
222.                            void *args, size_t size)
223.   {

crypto/async/async.c:224:5: 
222.                            void *args, size_t size)
223.   {
224. >     async_ctx *ctx = async_get_ctx();
225.       if (ctx == NULL)
226.           ctx = async_ctx_new();

crypto/async/async.c:98:1: start of procedure async_get_ctx()
  96.   }
  97.   
  98. > static async_ctx *async_get_ctx(void)
  99.   {
  100.       OPENSSL_INIT_crypto_library_start(OPENSSL_INIT_ASYNC, NULL);

crypto/async/async.c:100:5: Skipping OPENSSL_INIT_crypto_library_start(): empty list of specs
  98.   static async_ctx *async_get_ctx(void)
  99.   {
  100.       OPENSSL_INIT_crypto_library_start(OPENSSL_INIT_ASYNC, NULL);
             ^
  101.       return async_arch_get_ctx();
  102.   }

crypto/async/async.c:101:5: Skipping pthread_getspecific(): method has no implementation
  99.   {
  100.       OPENSSL_INIT_crypto_library_start(OPENSSL_INIT_ASYNC, NULL);
  101.       return async_arch_get_ctx();
             ^
  102.   }
  103.   

crypto/async/async.c:102:1: return from a call to async_get_ctx
  100.       OPENSSL_INIT_crypto_library_start(OPENSSL_INIT_ASYNC, NULL);
  101.       return async_arch_get_ctx();
  102. > }
  103.   
  104.   static int async_ctx_free(void)

crypto/async/async.c:225:9: Taking true branch
223.   {
224.       async_ctx *ctx = async_get_ctx();
225.       if (ctx == NULL)
               ^
226.           ctx = async_ctx_new();
227.       if (ctx == NULL) {

crypto/async/async.c:226:9: 
224.       async_ctx *ctx = async_get_ctx();
225.       if (ctx == NULL)
226. >         ctx = async_ctx_new();
227.       if (ctx == NULL) {
228.           return ASYNC_ERR;

crypto/async/async.c:75:1: start of procedure async_ctx_new()
  73.   static void async_free_pool_internal(async_pool *pool);
  74.   
  75. > static async_ctx *async_ctx_new(void)
  76.   {
  77.       async_ctx *nctx = NULL;

crypto/async/async.c:77:5: 
  75.   static async_ctx *async_ctx_new(void)
  76.   {
  77. >     async_ctx *nctx = NULL;
  78.   
  79.       nctx = OPENSSL_malloc(sizeof (async_ctx));

crypto/async/async.c:79:5: 
  77.       async_ctx *nctx = NULL;
  78.   
  79. >     nctx = OPENSSL_malloc(sizeof (async_ctx));
  80.       if (nctx == NULL) {
  81.           ASYNCerr(ASYNC_F_ASYNC_CTX_NEW, ERR_R_MALLOC_FAILURE);

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 (num <= 0)

crypto/mem.c:123:9: Taking false branch
    121.       void *ret = NULL;
    122.   
    123.       if (num <= 0)
                   ^
    124.           return NULL;
    125.   

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

crypto/mem.c:136:5: 
    134.       }
    135.   #else
    136. >     (void)file;
    137.       (void)line;
    138.       ret = malloc(num);

crypto/mem.c:137:5: 
    135.   #else
    136.       (void)file;
    137. >     (void)line;
    138.       ret = malloc(num);
    139.   #endif

crypto/mem.c:138:5: 
    136.       (void)file;
    137.       (void)line;
    138. >     ret = malloc(num);
    139.   #endif
    140.   

crypto/mem.c:153:5: 
    151.   #endif
    152.   
    153. >     return ret;
    154.   }
    155.   

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

crypto/async/async.c:80:9: Taking false branch
  78.   
  79.       nctx = OPENSSL_malloc(sizeof (async_ctx));
  80.       if (nctx == NULL) {
                ^
  81.           ASYNCerr(ASYNC_F_ASYNC_CTX_NEW, ERR_R_MALLOC_FAILURE);
  82.           goto err;

crypto/async/async.c:86:5: 
  84.   
  85.       async_fibre_init_dispatcher(&nctx->dispatcher);
  86. >     nctx->currjob = NULL;
  87.       nctx->blocked = 0;
  88.       if (!async_set_ctx(nctx))

crypto/async/async.c:87:5: 
  85.       async_fibre_init_dispatcher(&nctx->dispatcher);
  86.       nctx->currjob = NULL;
  87. >     nctx->blocked = 0;
  88.       if (!async_set_ctx(nctx))
  89.           goto err;

crypto/async/async.c:88:10: Taking false branch
  86.       nctx->currjob = NULL;
  87.       nctx->blocked = 0;
  88.       if (!async_set_ctx(nctx))
                 ^
  89.           goto err;
  90.   

crypto/async/async.c:91:5: 
  89.           goto err;
  90.   
  91. >     return nctx;
  92.   err:
  93.       OPENSSL_free(nctx);

crypto/async/async.c:96:1: return from a call to async_ctx_new
  94.   
  95.       return NULL;
  96. > }
  97.   
  98.   static async_ctx *async_get_ctx(void)

crypto/async/async.c:227:9: Taking false branch
225.       if (ctx == NULL)
226.           ctx = async_ctx_new();
227.       if (ctx == NULL) {
               ^
228.           return ASYNC_ERR;
229.       }

crypto/async/async.c:231:9: Taking false branch
229.       }
230.   
231.       if (*job) {
               ^
232.           ctx->currjob = *job;
233.       }

crypto/async/async.c:296:5: Loop condition is true. Entering loop body
294.               goto err;
295.           }
296.       }
           ^
297.   
298.   err:

crypto/async/async.c:236:13: Taking false branch
234.   
235.       for (;;) {
236.           if (ctx->currjob != NULL) {
                   ^
237.               if (ctx->currjob->status == ASYNC_JOB_STOPPING) {
238.                   *ret = ctx->currjob->ret;

crypto/async/async.c:273:13: Taking false branch
271.   
272.           /* Start a new job */
273.           if ((ctx->currjob = async_get_pool_job()) == NULL) {
                   ^
274.               return ASYNC_NO_JOBS;
275.           }

crypto/async/async.c:277:13: Taking true branch
275.           }
276.   
277.           if (args != NULL) {
                   ^
278.               ctx->currjob->funcargs = OPENSSL_malloc(size);
279.               if (ctx->currjob->funcargs == NULL) {

crypto/async/async.c:278:13: 
276.   
277.           if (args != NULL) {
278. >             ctx->currjob->funcargs = OPENSSL_malloc(size);
279.               if (ctx->currjob->funcargs == NULL) {
280.                   ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);

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 (num <= 0)

crypto/mem.c:123:9: Taking false branch
  121.       void *ret = NULL;
  122.   
  123.       if (num <= 0)
                 ^
  124.           return NULL;
  125.   

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

crypto/mem.c:136:5: 
  134.       }
  135.   #else
  136. >     (void)file;
  137.       (void)line;
  138.       ret = malloc(num);

crypto/mem.c:137:5: 
  135.   #else
  136.       (void)file;
  137. >     (void)line;
  138.       ret = malloc(num);
  139.   #endif

crypto/mem.c:138:5: 
  136.       (void)file;
  137.       (void)line;
  138. >     ret = malloc(num);
  139.   #endif
  140.   

crypto/mem.c:153:5: 
  151.   #endif
  152.   
  153. >     return ret;
  154.   }
  155.   

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

crypto/async/async.c:279:17: Taking true branch
277.           if (args != NULL) {
278.               ctx->currjob->funcargs = OPENSSL_malloc(size);
279.               if (ctx->currjob->funcargs == NULL) {
                       ^
280.                   ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);
281.                   async_release_job(ctx->currjob);

crypto/async/async.c:280:17: Skipping ERR_put_error(): empty list of specs
278.               ctx->currjob->funcargs = OPENSSL_malloc(size);
279.               if (ctx->currjob->funcargs == NULL) {
280.                   ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);
                       ^
281.                   async_release_job(ctx->currjob);
282.                   ctx->currjob = NULL;

crypto/async/async.c:281:17: 
279.               if (ctx->currjob->funcargs == NULL) {
280.                   ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);
281. >                 async_release_job(ctx->currjob);
282.                   ctx->currjob = NULL;
283.                   return ASYNC_ERR;

crypto/async/async.c:189:1: start of procedure async_release_job()
  187.   }
  188.   
  189. > static void async_release_job(ASYNC_JOB *job) {
  190.       async_pool *pool;
  191.   

crypto/async/async.c:192:5: Skipping pthread_getspecific(): method has no implementation
  190.       async_pool *pool;
  191.   
  192.       pool = async_get_pool();
             ^
  193.       OPENSSL_free(job->funcargs);
  194.       job->funcargs = NULL;

crypto/async/async.c:193:5: 
  191.   
  192.       pool = async_get_pool();
  193. >     OPENSSL_free(job->funcargs);
  194.       job->funcargs = NULL;
  195.       sk_ASYNC_JOB_push(pool->jobs, job);

crypto/mem.c:233:1: start of procedure CRYPTO_free()
    231.   }
    232.   
    233. > void CRYPTO_free(void *str)
    234.   {
    235.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:244:5: 
    242.       }
    243.   #else
    244. >     free(str);
    245.   #endif
    246.   }

crypto/mem.c:246:1: return from a call to CRYPTO_free
    244.       free(str);
    245.   #endif
    246. > }
    247.   
    248.   void CRYPTO_clear_free(void *str, size_t num)

crypto/async/async.c:194:5: 
  192.       pool = async_get_pool();
  193.       OPENSSL_free(job->funcargs);
  194. >     job->funcargs = NULL;
  195.       sk_ASYNC_JOB_push(pool->jobs, job);
  196.   }

crypto/async/async.c:195:5: 
  193.       OPENSSL_free(job->funcargs);
  194.       job->funcargs = NULL;
  195. >     sk_ASYNC_JOB_push(pool->jobs, job);
  196.   }
  197.   

crypto/async/async_locl.h:89:1: start of procedure sk_ASYNC_JOB_push()
    87.   };
    88.   
    89. > DEFINE_STACK_OF(ASYNC_JOB)
    90.   
    91.   struct async_pool_st {

crypto/stack/stack.c:258:1: start of procedure sk_push()
      256.   }
      257.   
      258. > int sk_push(_STACK *st, void *data)
      259.   {
      260.       return (sk_insert(st, data, st->num));

crypto/stack/stack.c:260:5: 
      258.   int sk_push(_STACK *st, void *data)
      259.   {
      260. >     return (sk_insert(st, data, st->num));
      261.   }
      262.   

crypto/stack/stack.c:166:1: start of procedure sk_insert()
        164.   }
        165.   
        166. > int sk_insert(_STACK *st, void *data, int loc)
        167.   {
        168.       char **s;

crypto/stack/stack.c:170:9: Taking false branch
        168.       char **s;
        169.   
        170.       if (st == NULL)
                       ^
        171.           return 0;
        172.       if (st->num_alloc <= st->num + 1) {

crypto/stack/stack.c:172:9: Taking false branch
        170.       if (st == NULL)
        171.           return 0;
        172.       if (st->num_alloc <= st->num + 1) {
                       ^
        173.           s = OPENSSL_realloc((char *)st->data,
        174.                               (unsigned int)sizeof(char *) * st->num_alloc * 2);

crypto/stack/stack.c:180:10: Taking true branch
        178.           st->num_alloc *= 2;
        179.       }
        180.       if ((loc >= (int)st->num) || (loc < 0))
                        ^
        181.           st->data[st->num] = data;
        182.       else {

crypto/stack/stack.c:181:9: 
        179.       }
        180.       if ((loc >= (int)st->num) || (loc < 0))
        181. >         st->data[st->num] = data;
        182.       else {
        183.           memmove(&(st->data[loc + 1]),

crypto/stack/stack.c:187:5: 
        185.           st->data[loc] = data;
        186.       }
        187. >     st->num++;
        188.       st->sorted = 0;
        189.       return (st->num);

crypto/stack/stack.c:188:5: 
        186.       }
        187.       st->num++;
        188. >     st->sorted = 0;
        189.       return (st->num);
        190.   }

crypto/stack/stack.c:189:5: 
        187.       st->num++;
        188.       st->sorted = 0;
        189. >     return (st->num);
        190.   }
        191.   

crypto/stack/stack.c:190:1: return from a call to sk_insert
        188.       st->sorted = 0;
        189.       return (st->num);
        190. > }
        191.   
        192.   void *sk_delete_ptr(_STACK *st, void *p)

crypto/stack/stack.c:261:1: return from a call to sk_push
      259.   {
      260.       return (sk_insert(st, data, st->num));
      261. > }
      262.   
      263.   int sk_unshift(_STACK *st, void *data)

crypto/async/async_locl.h:89:1: return from a call to sk_ASYNC_JOB_push
    87.   };
    88.   
    89. > DEFINE_STACK_OF(ASYNC_JOB)
    90.   
    91.   struct async_pool_st {

crypto/async/async.c:196:1: return from a call to async_release_job
  194.       job->funcargs = NULL;
  195.       sk_ASYNC_JOB_push(pool->jobs, job);
  196. > }
  197.   
  198.   void async_start_func(void)

crypto/async/async.c:282:17: 
280.                   ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);
281.                   async_release_job(ctx->currjob);
282. >                 ctx->currjob = NULL;
283.                   return ASYNC_ERR;
284.               }

int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),
                         void *args, size_t size)
{
    async_ctx *ctx = async_get_ctx();
    if (ctx == NULL)
        ctx = async_ctx_new();
    if (ctx == NULL) {
        return ASYNC_ERR;
    }
    if (*job) {
        ctx->currjob = *job;
    }
    for (;;) {
        if (ctx->currjob != NULL) {
            if (ctx->currjob->status == ASYNC_JOB_STOPPING) {
                *ret = ctx->currjob->ret;
                async_release_job(ctx->currjob);
                ctx->currjob = NULL;
                *job = NULL;
                return ASYNC_FINISH;
            }
            if (ctx->currjob->status == ASYNC_JOB_PAUSING) {
                *job = ctx->currjob;
                ctx->currjob->status = ASYNC_JOB_PAUSED;
                ctx->currjob = NULL;
                return ASYNC_PAUSE;
            }
            if (ctx->currjob->status == ASYNC_JOB_PAUSED) {
                ctx->currjob = *job;
                if (!async_fibre_swapcontext(&ctx->dispatcher,
                        &ctx->currjob->fibrectx, 1)) {
                    ASYNCerr(ASYNC_F_ASYNC_START_JOB,
                             ASYNC_R_FAILED_TO_SWAP_CONTEXT);
                    goto err;
                }
                continue;
            }
            ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_INTERNAL_ERROR);
            async_release_job(ctx->currjob);
            ctx->currjob = NULL;
            *job = NULL;
            return ASYNC_ERR;
        }
        if ((ctx->currjob = async_get_pool_job()) == NULL) {
            return ASYNC_NO_JOBS;
        }
        if (args != NULL) {
            ctx->currjob->funcargs = OPENSSL_malloc(size);
            if (ctx->currjob->funcargs == NULL) {
                ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);
                async_release_job(ctx->currjob);
                ctx->currjob = NULL;
                return ASYNC_ERR;
            }
            memcpy(ctx->currjob->funcargs, args, size);
        } else {
            ctx->currjob->funcargs = NULL;
        }
        ctx->currjob->func = func;
        if (!async_fibre_swapcontext(&ctx->dispatcher,
                &ctx->currjob->fibrectx, 1)) {
            ASYNCerr(ASYNC_F_ASYNC_START_JOB, ASYNC_R_FAILED_TO_SWAP_CONTEXT);
            goto err;
        }
    }
err:
    async_release_job(ctx->currjob);
    ctx->currjob = NULL;
    *job = NULL;
    return ASYNC_ERR;
}
['int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),\n                         void *args, size_t size)\n{\n    async_ctx *ctx = async_get_ctx();\n    if (ctx == NULL)\n        ctx = async_ctx_new();\n    if (ctx == NULL) {\n        return ASYNC_ERR;\n    }\n    if (*job) {\n        ctx->currjob = *job;\n    }\n    for (;;) {\n        if (ctx->currjob != NULL) {\n            if (ctx->currjob->status == ASYNC_JOB_STOPPING) {\n                *ret = ctx->currjob->ret;\n                async_release_job(ctx->currjob);\n                ctx->currjob = NULL;\n                *job = NULL;\n                return ASYNC_FINISH;\n            }\n            if (ctx->currjob->status == ASYNC_JOB_PAUSING) {\n                *job = ctx->currjob;\n                ctx->currjob->status = ASYNC_JOB_PAUSED;\n                ctx->currjob = NULL;\n                return ASYNC_PAUSE;\n            }\n            if (ctx->currjob->status == ASYNC_JOB_PAUSED) {\n                ctx->currjob = *job;\n                if (!async_fibre_swapcontext(&ctx->dispatcher,\n                        &ctx->currjob->fibrectx, 1)) {\n                    ASYNCerr(ASYNC_F_ASYNC_START_JOB,\n                             ASYNC_R_FAILED_TO_SWAP_CONTEXT);\n                    goto err;\n                }\n                continue;\n            }\n            ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_INTERNAL_ERROR);\n            async_release_job(ctx->currjob);\n            ctx->currjob = NULL;\n            *job = NULL;\n            return ASYNC_ERR;\n        }\n        if ((ctx->currjob = async_get_pool_job()) == NULL) {\n            return ASYNC_NO_JOBS;\n        }\n        if (args != NULL) {\n            ctx->currjob->funcargs = OPENSSL_malloc(size);\n            if (ctx->currjob->funcargs == NULL) {\n                ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);\n                async_release_job(ctx->currjob);\n                ctx->currjob = NULL;\n                return ASYNC_ERR;\n            }\n            memcpy(ctx->currjob->funcargs, args, size);\n        } else {\n            ctx->currjob->funcargs = NULL;\n        }\n        ctx->currjob->func = func;\n        if (!async_fibre_swapcontext(&ctx->dispatcher,\n                &ctx->currjob->fibrectx, 1)) {\n            ASYNCerr(ASYNC_F_ASYNC_START_JOB, ASYNC_R_FAILED_TO_SWAP_CONTEXT);\n            goto err;\n        }\n    }\nerr:\n    async_release_job(ctx->currjob);\n    ctx->currjob = NULL;\n    *job = NULL;\n    return ASYNC_ERR;\n}', 'static async_ctx *async_get_ctx(void)\n{\n    OPENSSL_INIT_crypto_library_start(OPENSSL_INIT_ASYNC, NULL);\n    return async_arch_get_ctx();\n}', 'static async_ctx *async_ctx_new(void)\n{\n    async_ctx *nctx = NULL;\n    nctx = OPENSSL_malloc(sizeof (async_ctx));\n    if (nctx == NULL) {\n        ASYNCerr(ASYNC_F_ASYNC_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    async_fibre_init_dispatcher(&nctx->dispatcher);\n    nctx->currjob = NULL;\n    nctx->blocked = 0;\n    if (!async_set_ctx(nctx))\n        goto err;\n    return nctx;\nerr:\n    OPENSSL_free(nctx);\n    return NULL;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\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    (void)file;\n    (void)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}', 'static void async_release_job(ASYNC_JOB *job) {\n    async_pool *pool;\n    pool = async_get_pool();\n    OPENSSL_free(job->funcargs);\n    job->funcargs = NULL;\n    sk_ASYNC_JOB_push(pool->jobs, job);\n}', 'void CRYPTO_free(void *str)\n{\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}', 'DEFINE_STACK_OF(ASYNC_JOB)', 'int sk_push(_STACK *st, void *data)\n{\n    return (sk_insert(st, data, st->num));\n}', 'int sk_insert(_STACK *st, void *data, int loc)\n{\n    char **s;\n    if (st == NULL)\n        return 0;\n    if (st->num_alloc <= st->num + 1) {\n        s = OPENSSL_realloc((char *)st->data,\n                            (unsigned int)sizeof(char *) * st->num_alloc * 2);\n        if (s == NULL)\n            return (0);\n        st->data = s;\n        st->num_alloc *= 2;\n    }\n    if ((loc >= (int)st->num) || (loc < 0))\n        st->data[st->num] = data;\n    else {\n        memmove(&(st->data[loc + 1]),\n                &(st->data[loc]), sizeof(char *) * (st->num - loc));\n        st->data[loc] = data;\n    }\n    st->num++;\n    st->sorted = 0;\n    return (st->num);\n}']