crypto/bn/bn_mont.c:522: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_MONT_CTX_new()` at line 518, column 11 is not reachable after line 522, column 9.
Showing all 76 steps of the trace


crypto/bn/bn_mont.c:499:1: start of procedure BN_MONT_CTX_set_locked()
497.   }
498.   
499. > BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
500.                                       const BIGNUM *mod, BN_CTX *ctx)
501.   {

crypto/bn/bn_mont.c:504:5: 
502.       BN_MONT_CTX *ret;
503.   
504. >     CRYPTO_r_lock(lock);
505.       ret = *pmont;
506.       CRYPTO_r_unlock(lock);

crypto/lock.c:414:1: start of procedure CRYPTO_lock()
  412.   }
  413.   
  414. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  415.   {
  416.   #ifdef LOCK_DEBUG

crypto/lock.c:441:9: Taking false branch
  439.       }
  440.   #endif
  441.       if (type < 0) {
                 ^
  442.           if (dynlock_lock_callback != NULL) {
  443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:452:16: Taking true branch
  450.               CRYPTO_destroy_dynlockid(type);
  451.           }
  452.       } else if (locking_callback != NULL)
                        ^
  453.           locking_callback(mode, type, file, line);
  454.   }

crypto/lock.c:453:9: Skipping __function_pointer__(): unresolved function pointer
  451.           }
  452.       } else if (locking_callback != NULL)
  453.           locking_callback(mode, type, file, line);
                 ^
  454.   }
  455.   

crypto/lock.c:441:5: 
  439.       }
  440.   #endif
  441. >     if (type < 0) {
  442.           if (dynlock_lock_callback != NULL) {
  443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:454:1: return from a call to CRYPTO_lock
  452.       } else if (locking_callback != NULL)
  453.           locking_callback(mode, type, file, line);
  454. > }
  455.   
  456.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/bn/bn_mont.c:505:5: 
503.   
504.       CRYPTO_r_lock(lock);
505. >     ret = *pmont;
506.       CRYPTO_r_unlock(lock);
507.       if (ret)

crypto/bn/bn_mont.c:506:5: 
504.       CRYPTO_r_lock(lock);
505.       ret = *pmont;
506. >     CRYPTO_r_unlock(lock);
507.       if (ret)
508.           return ret;

crypto/lock.c:414:1: start of procedure CRYPTO_lock()
  412.   }
  413.   
  414. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  415.   {
  416.   #ifdef LOCK_DEBUG

crypto/lock.c:441:9: Taking false branch
  439.       }
  440.   #endif
  441.       if (type < 0) {
                 ^
  442.           if (dynlock_lock_callback != NULL) {
  443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:452:16: Taking true branch
  450.               CRYPTO_destroy_dynlockid(type);
  451.           }
  452.       } else if (locking_callback != NULL)
                        ^
  453.           locking_callback(mode, type, file, line);
  454.   }

crypto/lock.c:453:9: Skipping __function_pointer__(): unresolved function pointer
  451.           }
  452.       } else if (locking_callback != NULL)
  453.           locking_callback(mode, type, file, line);
                 ^
  454.   }
  455.   

crypto/lock.c:441:5: 
  439.       }
  440.   #endif
  441. >     if (type < 0) {
  442.           if (dynlock_lock_callback != NULL) {
  443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:454:1: return from a call to CRYPTO_lock
  452.       } else if (locking_callback != NULL)
  453.           locking_callback(mode, type, file, line);
  454. > }
  455.   
  456.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/bn/bn_mont.c:507:9: Taking false branch
505.       ret = *pmont;
506.       CRYPTO_r_unlock(lock);
507.       if (ret)
               ^
508.           return ret;
509.   

crypto/bn/bn_mont.c:518:5: 
516.        * (the losers throw away the work they've done).
517.        */
518. >     ret = BN_MONT_CTX_new();
519.       if (ret == NULL)
520.           return NULL;

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. >     (void)file;
    140.       (void)line;
    141.       ret = malloc(num);

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

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

crypto/mem.c:156:5: 
    154.   #endif
    155.   
    156. >     return ret;
    157.   }
    158.   

crypto/mem.c:157:1: return from a call to CRYPTO_malloc
    155.   
    156.       return ret;
    157. > }
    158.   
    159.   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/bn/bn_mont.c:519:9: Taking false branch
517.        */
518.       ret = BN_MONT_CTX_new();
519.       if (ret == NULL)
               ^
520.           return NULL;
521.       if (!BN_MONT_CTX_set(ret, mod, ctx)) {

crypto/bn/bn_mont.c:521:10: 
519.       if (ret == NULL)
520.           return NULL;
521. >     if (!BN_MONT_CTX_set(ret, mod, ctx)) {
522.           BN_MONT_CTX_free(ret);
523.           return 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:235:1: start of procedure BN_CTX_start()
    233.   }
    234.   
    235. > void BN_CTX_start(BN_CTX *ctx)
    236.   {
    237.       CTXDBG_ENTRY("BN_CTX_start", ctx);

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

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

crypto/bn/bn_ctx.c:239:5: 
    237.       CTXDBG_ENTRY("BN_CTX_start", ctx);
    238.       /* If we're already overflowing ... */
    239. >     if (ctx->err_stack || ctx->too_many)
    240.           ctx->err_stack++;
    241.       /* (Try to) get a new frame pointer */

crypto/bn/bn_ctx.c:247:1: return from a call to BN_CTX_start
    245.       }
    246.       CTXDBG_EXIT(ctx);
    247. > }
    248.   
    249.   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:266:1: start of procedure BN_CTX_get()
    264.   }
    265.   
    266. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    267.   {
    268.       BIGNUM *ret;

crypto/bn/bn_ctx.c:271:9: Taking true branch
    269.   
    270.       CTXDBG_ENTRY("BN_CTX_get", ctx);
    271.       if (ctx->err_stack || ctx->too_many)
                   ^
    272.           return NULL;
    273.       if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {

crypto/bn/bn_ctx.c:272:9: 
    270.       CTXDBG_ENTRY("BN_CTX_get", ctx);
    271.       if (ctx->err_stack || ctx->too_many)
    272. >         return NULL;
    273.       if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {
    274.           /*

crypto/bn/bn_ctx.c:287:1: return from a call to BN_CTX_get
    285.       CTXDBG_RET(ctx, ret);
    286.       return ret;
    287. > }
    288.   
    289.   /************/

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:249:1: start of procedure BN_CTX_end()
    247.   }
    248.   
    249. > void BN_CTX_end(BN_CTX *ctx)
    250.   {
    251.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:252:9: Taking true branch
    250.   {
    251.       CTXDBG_ENTRY("BN_CTX_end", ctx);
    252.       if (ctx->err_stack)
                   ^
    253.           ctx->err_stack--;
    254.       else {

crypto/bn/bn_ctx.c:253:9: 
    251.       CTXDBG_ENTRY("BN_CTX_end", ctx);
    252.       if (ctx->err_stack)
    253. >         ctx->err_stack--;
    254.       else {
    255.           unsigned int fp = BN_STACK_pop(&ctx->stack);

crypto/bn/bn_ctx.c:252:5: 
    250.   {
    251.       CTXDBG_ENTRY("BN_CTX_end", ctx);
    252. >     if (ctx->err_stack)
    253.           ctx->err_stack--;
    254.       else {

crypto/bn/bn_ctx.c:264:1: return from a call to BN_CTX_end
    262.       }
    263.       CTXDBG_EXIT(ctx);
    264. > }
    265.   
    266.   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/bn/bn_mont.c:521:10: Taking true branch
519.       if (ret == NULL)
520.           return NULL;
521.       if (!BN_MONT_CTX_set(ret, mod, ctx)) {
                ^
522.           BN_MONT_CTX_free(ret);
523.           return NULL;

crypto/bn/bn_mont.c:522:9: Skipping BN_MONT_CTX_free(): empty list of specs
520.           return NULL;
521.       if (!BN_MONT_CTX_set(ret, mod, ctx)) {
522.           BN_MONT_CTX_free(ret);
               ^
523.           return NULL;
524.       }
