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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/bn/bn_ctx.c:236:1: start of procedure BN_CTX_start()
  234.   }
  235.   
  236. > void BN_CTX_start(BN_CTX *ctx)
  237.   {
  238.       CTXDBG_ENTRY("BN_CTX_start", ctx);

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

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

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

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

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

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

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

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

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
      118.   }
      119.   
      120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122.       void *ret = NULL;

crypto/mem.c:122:5: 
      120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122. >     void *ret = NULL;
      123.   
      124.       if (num <= 0)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/bn/bn_ctx.c:248:1: return from a call to BN_CTX_start
  246.       }
  247.       CTXDBG_EXIT(ctx);
  248. > }
  249.   
  250.   void BN_CTX_end(BN_CTX *ctx)

crypto/bn/bn_exp.c:701:9: Taking false branch
699.        * this is not done, things will break in the montgomery part.
700.        */
701.       if (in_mont != NULL)
               ^
702.           mont = in_mont;
703.       else {

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

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

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

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
    118.   }
    119.   
    120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    121.   {
    122.       void *ret = NULL;

crypto/mem.c:122:5: 
    120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    121.   {
    122. >     void *ret = NULL;
    123.   
    124.       if (num <= 0)

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

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

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

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

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

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

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

crypto/bn/bn_mont.c:319:9: Taking false branch
  317.       BN_MONT_CTX *ret;
  318.   
  319.       if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
                 ^
  320.           return (NULL);
  321.   

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

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

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

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

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

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

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

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

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

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

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

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

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

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