crypto/bn/bn_exp.c:705: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_CTX_start()` at line 694, column 5 is not reachable after line 705, column 14.
Showing all 89 steps of the trace


crypto/bn/bn_exp.c:654:1: start of procedure BN_mod_exp_mont_consttime()
652.    * http://www.daemonology.net/hyperthreading-considered-harmful/)
653.    */
654. > int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
655.                                 const BIGNUM *m, BN_CTX *ctx,
656.                                 BN_MONT_CTX *in_mont)

crypto/bn/bn_exp.c:658:5: 
656.                                 BN_MONT_CTX *in_mont)
657.   {
658. >     int i, bits, ret = 0, window, wvalue;
659.       int top;
660.       BN_MONT_CTX *mont = NULL;

crypto/bn/bn_exp.c:660:5: 
658.       int i, bits, ret = 0, window, wvalue;
659.       int top;
660. >     BN_MONT_CTX *mont = NULL;
661.   
662.       int numPowers;

crypto/bn/bn_exp.c:663:5: 
661.   
662.       int numPowers;
663. >     unsigned char *powerbufFree = NULL;
664.       int powerbufLen = 0;
665.       unsigned char *powerbuf = NULL;

crypto/bn/bn_exp.c:664:5: 
662.       int numPowers;
663.       unsigned char *powerbufFree = NULL;
664. >     int powerbufLen = 0;
665.       unsigned char *powerbuf = NULL;
666.       BIGNUM tmp, am;

crypto/bn/bn_exp.c:665:5: 
663.       unsigned char *powerbufFree = NULL;
664.       int powerbufLen = 0;
665. >     unsigned char *powerbuf = NULL;
666.       BIGNUM tmp, am;
667.   #if defined(SPARC_T4_MONT)

crypto/bn/bn_exp.c:675:10: 
673.       bn_check_top(m);
674.   
675. >     if (!BN_is_odd(m)) {
676.           BNerr(BN_F_BN_MOD_EXP_MONT_CONSTTIME, BN_R_CALLED_WITH_EVEN_MODULUS);
677.           return (0);

crypto/bn/bn_lib.c:913:1: start of procedure BN_is_odd()
  911.   }
  912.   
  913. > int BN_is_odd(const BIGNUM *a)
  914.   {
  915.       return (a->top > 0) && (a->d[0] & 1);

crypto/bn/bn_lib.c:915:13: Condition is true
  913.   int BN_is_odd(const BIGNUM *a)
  914.   {
  915.       return (a->top > 0) && (a->d[0] & 1);
                     ^
  916.   }
  917.   

crypto/bn/bn_lib.c:915:29: Condition is true
  913.   int BN_is_odd(const BIGNUM *a)
  914.   {
  915.       return (a->top > 0) && (a->d[0] & 1);
                                     ^
  916.   }
  917.   

crypto/bn/bn_lib.c:915:12: 
  913.   int BN_is_odd(const BIGNUM *a)
  914.   {
  915. >     return (a->top > 0) && (a->d[0] & 1);
  916.   }
  917.   

crypto/bn/bn_lib.c:915:5: 
  913.   int BN_is_odd(const BIGNUM *a)
  914.   {
  915. >     return (a->top > 0) && (a->d[0] & 1);
  916.   }
  917.   

crypto/bn/bn_lib.c:916:1: return from a call to BN_is_odd
  914.   {
  915.       return (a->top > 0) && (a->d[0] & 1);
  916. > }
  917.   
  918.   int BN_is_negative(const BIGNUM *a)

crypto/bn/bn_exp.c:675:10: Taking false branch
673.       bn_check_top(m);
674.   
675.       if (!BN_is_odd(m)) {
                ^
676.           BNerr(BN_F_BN_MOD_EXP_MONT_CONSTTIME, BN_R_CALLED_WITH_EVEN_MODULUS);
677.           return (0);

crypto/bn/bn_exp.c:680:5: 
678.       }
679.   
680. >     top = m->top;
681.   
682.       bits = BN_num_bits(p);

crypto/bn/bn_exp.c:682:5: 
680.       top = m->top;
681.   
682. >     bits = BN_num_bits(p);
683.       if (bits == 0) {
684.           /* x**0 mod 1 is still zero. */

crypto/bn/bn_lib.c:214:1: start of procedure BN_num_bits()
  212.   }
  213.   
  214. > int BN_num_bits(const BIGNUM *a)
  215.   {
  216.       int i = a->top - 1;

crypto/bn/bn_lib.c:216:5: 
  214.   int BN_num_bits(const BIGNUM *a)
  215.   {
  216. >     int i = a->top - 1;
  217.       bn_check_top(a);
  218.   

crypto/bn/bn_lib.c:219:9: 
  217.       bn_check_top(a);
  218.   
  219. >     if (BN_is_zero(a))
  220.           return 0;
  221.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));

crypto/bn/bn_lib.c:898:1: start of procedure BN_is_zero()
    896.   }
    897.   
    898. > int BN_is_zero(const BIGNUM *a)
    899.   {
    900.       return a->top == 0;

crypto/bn/bn_lib.c:900:12: Condition is false
    898.   int BN_is_zero(const BIGNUM *a)
    899.   {
    900.       return a->top == 0;
                      ^
    901.   }
    902.   

crypto/bn/bn_lib.c:900:5: 
    898.   int BN_is_zero(const BIGNUM *a)
    899.   {
    900. >     return a->top == 0;
    901.   }
    902.   

crypto/bn/bn_lib.c:901:1: return from a call to BN_is_zero
    899.   {
    900.       return a->top == 0;
    901. > }
    902.   
    903.   int BN_is_one(const BIGNUM *a)

crypto/bn/bn_lib.c:219:9: Taking false branch
  217.       bn_check_top(a);
  218.   
  219.       if (BN_is_zero(a))
                 ^
  220.           return 0;
  221.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));

crypto/bn/bn_lib.c:221:5: Skipping BN_num_bits_word(): empty list of specs
  219.       if (BN_is_zero(a))
  220.           return 0;
  221.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
             ^
  222.   }
  223.   

crypto/bn/bn_lib.c:222:1: return from a call to BN_num_bits
  220.           return 0;
  221.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
  222. > }
  223.   
  224.   static void bn_free_d(BIGNUM *a)

crypto/bn/bn_exp.c:683:9: Taking false branch
681.   
682.       bits = BN_num_bits(p);
683.       if (bits == 0) {
               ^
684.           /* x**0 mod 1 is still zero. */
685.           if (BN_is_one(m)) {

crypto/bn/bn_exp.c:694:5: 
692.       }
693.   
694. >     BN_CTX_start(ctx);
695.   
696.       /*

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 false 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:239:27: Taking false 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:242:15: 
  240.           ctx->err_stack++;
  241.       /* (Try to) get a new frame pointer */
  242. >     else if (!BN_STACK_push(&ctx->stack, ctx->used)) {
  243.           BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);
  244.           ctx->err_stack++;

crypto/bn/bn_ctx.c:306:1: start of procedure BN_STACK_push()
    304.   
    305.   
    306. > static int BN_STACK_push(BN_STACK *st, unsigned int idx)
    307.   {
    308.       if (st->depth == st->size) {

crypto/bn/bn_ctx.c:308:9: Taking true branch
    306.   static int BN_STACK_push(BN_STACK *st, unsigned int idx)
    307.   {
    308.       if (st->depth == st->size) {
                   ^
    309.           /* Need to expand */
    310.           unsigned int newsize =

crypto/bn/bn_ctx.c:311:13: Condition is true
    309.           /* Need to expand */
    310.           unsigned int newsize =
    311.               st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES;
                       ^
    312.           unsigned int *newitems = OPENSSL_malloc(sizeof(*newitems) * newsize);
    313.           if (newitems == NULL)

crypto/bn/bn_ctx.c:310:9: 
    308.       if (st->depth == st->size) {
    309.           /* Need to expand */
    310. >         unsigned int newsize =
    311.               st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES;
    312.           unsigned int *newitems = OPENSSL_malloc(sizeof(*newitems) * newsize);

crypto/bn/bn_ctx.c:312:9: 
    310.           unsigned int newsize =
    311.               st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES;
    312. >         unsigned int *newitems = OPENSSL_malloc(sizeof(*newitems) * newsize);
    313.           if (newitems == NULL)
    314.               return 0;

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/bn/bn_ctx.c:313:13: Taking false branch
    311.               st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES;
    312.           unsigned int *newitems = OPENSSL_malloc(sizeof(*newitems) * newsize);
    313.           if (newitems == NULL)
                       ^
    314.               return 0;
    315.           if (st->depth)

crypto/bn/bn_ctx.c:315:13: Taking true branch
    313.           if (newitems == NULL)
    314.               return 0;
    315.           if (st->depth)
                       ^
    316.               memcpy(newitems, st->indexes, sizeof(*newitems) * st->depth);
    317.           OPENSSL_free(st->indexes);

crypto/bn/bn_ctx.c:316:13: 
    314.               return 0;
    315.           if (st->depth)
    316. >             memcpy(newitems, st->indexes, sizeof(*newitems) * st->depth);
    317.           OPENSSL_free(st->indexes);
    318.           st->indexes = newitems;

crypto/bn/bn_ctx.c:317:9: 
    315.           if (st->depth)
    316.               memcpy(newitems, st->indexes, sizeof(*newitems) * st->depth);
    317. >         OPENSSL_free(st->indexes);
    318.           st->indexes = newitems;
    319.           st->size = newsize;

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/bn/bn_ctx.c:318:9: 
    316.               memcpy(newitems, st->indexes, sizeof(*newitems) * st->depth);
    317.           OPENSSL_free(st->indexes);
    318. >         st->indexes = newitems;
    319.           st->size = newsize;
    320.       }

crypto/bn/bn_ctx.c:319:9: 
    317.           OPENSSL_free(st->indexes);
    318.           st->indexes = newitems;
    319. >         st->size = newsize;
    320.       }
    321.       st->indexes[(st->depth)++] = idx;

crypto/bn/bn_ctx.c:321:5: 
    319.           st->size = newsize;
    320.       }
    321. >     st->indexes[(st->depth)++] = idx;
    322.       return 1;
    323.   }

crypto/bn/bn_ctx.c:322:5: 
    320.       }
    321.       st->indexes[(st->depth)++] = idx;
    322. >     return 1;
    323.   }
    324.   

crypto/bn/bn_ctx.c:323:1: return from a call to BN_STACK_push
    321.       st->indexes[(st->depth)++] = idx;
    322.       return 1;
    323. > }
    324.   
    325.   static unsigned int BN_STACK_pop(BN_STACK *st)

crypto/bn/bn_ctx.c:242:15: Taking false branch
  240.           ctx->err_stack++;
  241.       /* (Try to) get a new frame pointer */
  242.       else if (!BN_STACK_push(&ctx->stack, ctx->used)) {
                       ^
  243.           BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);
  244.           ctx->err_stack++;

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_exp.c:700:9: Taking false branch
698.        * this is not done, things will break in the montgomery part.
699.        */
700.       if (in_mont != NULL)
               ^
701.           mont = in_mont;
702.       else {

crypto/bn/bn_exp.c:703:13: 
701.           mont = in_mont;
702.       else {
703. >         if ((mont = BN_MONT_CTX_new()) == NULL)
704.               goto err;
705.           if (!BN_MONT_CTX_set(mont, m, ctx))

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 (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/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_exp.c:703:13: Taking false branch
701.           mont = in_mont;
702.       else {
703.           if ((mont = BN_MONT_CTX_new()) == NULL)
                   ^
704.               goto err;
705.           if (!BN_MONT_CTX_set(mont, m, ctx))

crypto/bn/bn_exp.c:705:14: Skipping BN_MONT_CTX_set(): empty list of specs
703.           if ((mont = BN_MONT_CTX_new()) == NULL)
704.               goto err;
705.           if (!BN_MONT_CTX_set(mont, m, ctx))
                    ^
706.               goto err;
707.       }
