crypto/ec/ec_lib.c:1009: error: MEMORY_LEAK
  memory dynamically allocated to `group->mont_data` by call to `BN_MONT_CTX_new()` at line 1003, column 24 is not reachable after line 1009, column 9.
Showing all 66 steps of the trace


crypto/ec/ec_lib.c:992:1: start of procedure ec_precompute_mont_data()
990.    * returns one on success. On error it returns zero.
991.    */
992. > int ec_precompute_mont_data(EC_GROUP *group)
993.   {
994.       BN_CTX *ctx = BN_CTX_new();

crypto/ec/ec_lib.c:994:5: Skipping BN_CTX_new(): empty list of specs
992.   int ec_precompute_mont_data(EC_GROUP *group)
993.   {
994.       BN_CTX *ctx = BN_CTX_new();
           ^
995.       int ret = 0;
996.   

crypto/ec/ec_lib.c:995:5: 
993.   {
994.       BN_CTX *ctx = BN_CTX_new();
995. >     int ret = 0;
996.   
997.       BN_MONT_CTX_free(group->mont_data);

crypto/ec/ec_lib.c:997:5: Skipping BN_MONT_CTX_free(): empty list of specs
995.       int ret = 0;
996.   
997.       BN_MONT_CTX_free(group->mont_data);
            ^
998.       group->mont_data = NULL;
999.   

crypto/ec/ec_lib.c:998:5: 
996.   
997.       BN_MONT_CTX_free(group->mont_data);
998. >     group->mont_data = NULL;
999.   
1000.       if (ctx == NULL)

crypto/ec/ec_lib.c:1000:9: Taking false branch
998.       group->mont_data = NULL;
999.   
1000.       if (ctx == NULL)
                ^
1001.           goto err;
1002.   

crypto/ec/ec_lib.c:1003:5: 
1001.           goto err;
1002.   
1003. >     group->mont_data = BN_MONT_CTX_new();
1004.       if (group->mont_data == NULL)
1005.           goto err;

crypto/bn/bn_mont.c:314:1: start of procedure BN_MONT_CTX_new()
  312.   }
  313.   
  314. > BN_MONT_CTX *BN_MONT_CTX_new(void)
  315.   {
  316.       BN_MONT_CTX *ret;

crypto/bn/bn_mont.c:318:9: 
  316.       BN_MONT_CTX *ret;
  317.   
  318. >     if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
  319.           return (NULL);
  320.   

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/bn/bn_mont.c:318:9: Taking false branch
  316.       BN_MONT_CTX *ret;
  317.   
  318.       if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
                 ^
  319.           return (NULL);
  320.   

crypto/bn/bn_mont.c:321:5: 
  319.           return (NULL);
  320.   
  321. >     BN_MONT_CTX_init(ret);
  322.       ret->flags = BN_FLG_MALLOCED;
  323.       return (ret);

crypto/bn/bn_mont.c:326:1: start of procedure BN_MONT_CTX_init()
    324.   }
    325.   
    326. > void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    327.   {
    328.       ctx->ri = 0;

crypto/bn/bn_mont.c:328:5: 
    326.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    327.   {
    328. >     ctx->ri = 0;
    329.       bn_init(&(ctx->RR));
    330.       bn_init(&(ctx->N));

crypto/bn/bn_mont.c:329:5: Skipping bn_init(): empty list of specs
    327.   {
    328.       ctx->ri = 0;
    329.       bn_init(&(ctx->RR));
               ^
    330.       bn_init(&(ctx->N));
    331.       bn_init(&(ctx->Ni));

crypto/bn/bn_mont.c:330:5: Skipping bn_init(): empty list of specs
    328.       ctx->ri = 0;
    329.       bn_init(&(ctx->RR));
    330.       bn_init(&(ctx->N));
               ^
    331.       bn_init(&(ctx->Ni));
    332.       ctx->n0[0] = ctx->n0[1] = 0;

crypto/bn/bn_mont.c:331:5: Skipping bn_init(): empty list of specs
    329.       bn_init(&(ctx->RR));
    330.       bn_init(&(ctx->N));
    331.       bn_init(&(ctx->Ni));
               ^
    332.       ctx->n0[0] = ctx->n0[1] = 0;
    333.       ctx->flags = 0;

crypto/bn/bn_mont.c:332:5: 
    330.       bn_init(&(ctx->N));
    331.       bn_init(&(ctx->Ni));
    332. >     ctx->n0[0] = ctx->n0[1] = 0;
    333.       ctx->flags = 0;
    334.   }

crypto/bn/bn_mont.c:333:5: 
    331.       bn_init(&(ctx->Ni));
    332.       ctx->n0[0] = ctx->n0[1] = 0;
    333. >     ctx->flags = 0;
    334.   }
    335.   

crypto/bn/bn_mont.c:334:1: return from a call to BN_MONT_CTX_init
    332.       ctx->n0[0] = ctx->n0[1] = 0;
    333.       ctx->flags = 0;
    334. > }
    335.   
    336.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)

crypto/bn/bn_mont.c:322:5: 
  320.   
  321.       BN_MONT_CTX_init(ret);
  322. >     ret->flags = BN_FLG_MALLOCED;
  323.       return (ret);
  324.   }

crypto/bn/bn_mont.c:323:5: 
  321.       BN_MONT_CTX_init(ret);
  322.       ret->flags = BN_FLG_MALLOCED;
  323. >     return (ret);
  324.   }
  325.   

crypto/bn/bn_mont.c:324:1: return from a call to BN_MONT_CTX_new
  322.       ret->flags = BN_FLG_MALLOCED;
  323.       return (ret);
  324. > }
  325.   
  326.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)

crypto/ec/ec_lib.c:1004:9: Taking false branch
1002.   
1003.       group->mont_data = BN_MONT_CTX_new();
1004.       if (group->mont_data == NULL)
                ^
1005.           goto err;
1006.   

crypto/ec/ec_lib.c:1007:10: 
1005.           goto err;
1006.   
1007. >     if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
1008.           BN_MONT_CTX_free(group->mont_data);
1009.           group->mont_data = NULL;

crypto/bn/bn_mont.c:348:1: start of procedure BN_MONT_CTX_set()
  346.   }
  347.   
  348. > int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
  349.   {
  350.       int ret = 0;

crypto/bn/bn_mont.c:350:5: 
  348.   int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
  349.   {
  350. >     int ret = 0;
  351.       BIGNUM *Ri, *R;
  352.   

crypto/bn/bn_mont.c:353:9: 
  351.       BIGNUM *Ri, *R;
  352.   
  353. >     if (BN_is_zero(mod))
  354.           return 0;
  355.   

crypto/bn/bn_lib.c:975:1: start of procedure BN_is_zero()
    973.   }
    974.   
    975. > int BN_is_zero(const BIGNUM *a)
    976.   {
    977.       return a->top == 0;

crypto/bn/bn_lib.c:977:12: Condition is false
    975.   int BN_is_zero(const BIGNUM *a)
    976.   {
    977.       return a->top == 0;
                      ^
    978.   }
    979.   

crypto/bn/bn_lib.c:977:5: 
    975.   int BN_is_zero(const BIGNUM *a)
    976.   {
    977. >     return a->top == 0;
    978.   }
    979.   

crypto/bn/bn_lib.c:978:1: return from a call to BN_is_zero
    976.   {
    977.       return a->top == 0;
    978. > }
    979.   
    980.   int BN_is_one(const BIGNUM *a)

crypto/bn/bn_mont.c:353:9: Taking false branch
  351.       BIGNUM *Ri, *R;
  352.   
  353.       if (BN_is_zero(mod))
                 ^
  354.           return 0;
  355.   

crypto/bn/bn_mont.c:356:5: 
  354.           return 0;
  355.   
  356. >     BN_CTX_start(ctx);
  357.       if ((Ri = BN_CTX_get(ctx)) == NULL)
  358.           goto err;

crypto/bn/bn_ctx.c:227:1: start of procedure BN_CTX_start()
    225.   }
    226.   
    227. > void BN_CTX_start(BN_CTX *ctx)
    228.   {
    229.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_ctx.c:231:9: Taking true branch
    229.       CTXDBG_ENTRY("BN_CTX_start", ctx);
    230.       /* If we're already overflowing ... */
    231.       if (ctx->err_stack || ctx->too_many)
                   ^
    232.           ctx->err_stack++;
    233.       /* (Try to) get a new frame pointer */

crypto/bn/bn_ctx.c:232:9: 
    230.       /* If we're already overflowing ... */
    231.       if (ctx->err_stack || ctx->too_many)
    232. >         ctx->err_stack++;
    233.       /* (Try to) get a new frame pointer */
    234.       else if (!BN_STACK_push(&ctx->stack, ctx->used)) {

crypto/bn/bn_ctx.c:231:5: 
    229.       CTXDBG_ENTRY("BN_CTX_start", ctx);
    230.       /* If we're already overflowing ... */
    231. >     if (ctx->err_stack || ctx->too_many)
    232.           ctx->err_stack++;
    233.       /* (Try to) get a new frame pointer */

crypto/bn/bn_ctx.c:239:1: return from a call to BN_CTX_start
    237.       }
    238.       CTXDBG_EXIT(ctx);
    239. > }
    240.   
    241.   void BN_CTX_end(BN_CTX *ctx)

crypto/bn/bn_mont.c:357:9: 
  355.   
  356.       BN_CTX_start(ctx);
  357. >     if ((Ri = BN_CTX_get(ctx)) == NULL)
  358.           goto err;
  359.       R = &(mont->RR);            /* grab RR as a temp */

crypto/bn/bn_ctx.c:258:1: start of procedure BN_CTX_get()
    256.   }
    257.   
    258. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    259.   {
    260.       BIGNUM *ret;

crypto/bn/bn_ctx.c:263:9: Taking true branch
    261.   
    262.       CTXDBG_ENTRY("BN_CTX_get", ctx);
    263.       if (ctx->err_stack || ctx->too_many)
                   ^
    264.           return NULL;
    265.       if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {

crypto/bn/bn_ctx.c:264:9: 
    262.       CTXDBG_ENTRY("BN_CTX_get", ctx);
    263.       if (ctx->err_stack || ctx->too_many)
    264. >         return NULL;
    265.       if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {
    266.           /*

crypto/bn/bn_ctx.c:279:1: return from a call to BN_CTX_get
    277.       CTXDBG_RET(ctx, ret);
    278.       return ret;
    279. > }
    280.   
    281.   /************/

crypto/bn/bn_mont.c:357:9: Taking true branch
  355.   
  356.       BN_CTX_start(ctx);
  357.       if ((Ri = BN_CTX_get(ctx)) == NULL)
                 ^
  358.           goto err;
  359.       R = &(mont->RR);            /* grab RR as a temp */

crypto/bn/bn_mont.c:477:2: 
  475.   
  476.       ret = 1;
  477. >  err:
  478.       BN_CTX_end(ctx);
  479.       return ret;

crypto/bn/bn_mont.c:478:5: 
  476.       ret = 1;
  477.    err:
  478. >     BN_CTX_end(ctx);
  479.       return ret;
  480.   }

crypto/bn/bn_ctx.c:241:1: start of procedure BN_CTX_end()
    239.   }
    240.   
    241. > void BN_CTX_end(BN_CTX *ctx)
    242.   {
    243.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:244:9: Taking true branch
    242.   {
    243.       CTXDBG_ENTRY("BN_CTX_end", ctx);
    244.       if (ctx->err_stack)
                   ^
    245.           ctx->err_stack--;
    246.       else {

crypto/bn/bn_ctx.c:245:9: 
    243.       CTXDBG_ENTRY("BN_CTX_end", ctx);
    244.       if (ctx->err_stack)
    245. >         ctx->err_stack--;
    246.       else {
    247.           unsigned int fp = BN_STACK_pop(&ctx->stack);

crypto/bn/bn_ctx.c:244:5: 
    242.   {
    243.       CTXDBG_ENTRY("BN_CTX_end", ctx);
    244. >     if (ctx->err_stack)
    245.           ctx->err_stack--;
    246.       else {

crypto/bn/bn_ctx.c:256:1: return from a call to BN_CTX_end
    254.       }
    255.       CTXDBG_EXIT(ctx);
    256. > }
    257.   
    258.   BIGNUM *BN_CTX_get(BN_CTX *ctx)

crypto/bn/bn_mont.c:479:5: 
  477.    err:
  478.       BN_CTX_end(ctx);
  479. >     return ret;
  480.   }
  481.   

crypto/bn/bn_mont.c:480:1: return from a call to BN_MONT_CTX_set
  478.       BN_CTX_end(ctx);
  479.       return ret;
  480. > }
  481.   
  482.   BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)

crypto/ec/ec_lib.c:1007:10: Taking true branch
1005.           goto err;
1006.   
1007.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
                 ^
1008.           BN_MONT_CTX_free(group->mont_data);
1009.           group->mont_data = NULL;

crypto/ec/ec_lib.c:1008:9: Skipping BN_MONT_CTX_free(): empty list of specs
1006.   
1007.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
1008.           BN_MONT_CTX_free(group->mont_data);
                ^
1009.           group->mont_data = NULL;
1010.           goto err;

crypto/ec/ec_lib.c:1009:9: 
1007.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
1008.           BN_MONT_CTX_free(group->mont_data);
1009. >         group->mont_data = NULL;
1010.           goto err;
1011.       }
