crypto/bn/bn_gf2m.c:1072: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_CTX_start()` at line 1066, column 5 is not reachable after line 1072, column 11.
Showing all 80 steps of the trace


crypto/bn/bn_gf2m.c:1052:1: start of procedure BN_GF2m_mod_sqrt_arr()
1050.    * r could be a. Uses exponentiation as in algorithm A.4.1 from IEEE P1363.
1051.    */
1052. > int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, const int p[],
1053.                            BN_CTX *ctx)
1054.   {

crypto/bn/bn_gf2m.c:1055:5: 
1053.                            BN_CTX *ctx)
1054.   {
1055. >     int ret = 0;
1056.       BIGNUM *u;
1057.   

crypto/bn/bn_gf2m.c:1060:10: Taking false branch
1058.       bn_check_top(a);
1059.   
1060.       if (!p[0]) {
                 ^
1061.           /* reduction mod 1 => return 0 */
1062.           BN_zero(r);

crypto/bn/bn_gf2m.c:1066:5: 
1064.       }
1065.   
1066. >     BN_CTX_start(ctx);
1067.       if ((u = BN_CTX_get(ctx)) == NULL)
1068.           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 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_gf2m.c:1067:9: 
1065.   
1066.       BN_CTX_start(ctx);
1067. >     if ((u = BN_CTX_get(ctx)) == NULL)
1068.           goto err;
1069.   

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 false 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:271:27: Taking false 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:273:9: Taking false branch
  271.       if (ctx->err_stack || ctx->too_many)
  272.           return NULL;
  273.       if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {
                 ^
  274.           /*
  275.            * Setting too_many prevents repeated "get" attempts from cluttering

crypto/bn/bn_ctx.c:283:5: 
  281.       }
  282.       /* OK, make sure the returned bignum is "zero" */
  283. >     BN_zero(ret);
  284.       ctx->used++;
  285.       CTXDBG_RET(ctx, ret);

crypto/bn/bn_lib.c:520:1: start of procedure BN_set_word()
    518.   }
    519.   
    520. > int BN_set_word(BIGNUM *a, BN_ULONG w)
    521.   {
    522.       bn_check_top(a);

crypto/bn/bn_lib.c:523:9: Condition is true
    521.   {
    522.       bn_check_top(a);
    523.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    524.           return (0);
    525.       a->neg = 0;

crypto/bn/bn_lib.c:523:9: Taking false branch
    521.   {
    522.       bn_check_top(a);
    523.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                   ^
    524.           return (0);
    525.       a->neg = 0;

crypto/bn/bn_lib.c:525:5: 
    523.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
    524.           return (0);
    525. >     a->neg = 0;
    526.       a->d[0] = w;
    527.       a->top = (w ? 1 : 0);

crypto/bn/bn_lib.c:526:5: 
    524.           return (0);
    525.       a->neg = 0;
    526. >     a->d[0] = w;
    527.       a->top = (w ? 1 : 0);
    528.       bn_check_top(a);

crypto/bn/bn_lib.c:527:15: Condition is false
    525.       a->neg = 0;
    526.       a->d[0] = w;
    527.       a->top = (w ? 1 : 0);
                         ^
    528.       bn_check_top(a);
    529.       return (1);

crypto/bn/bn_lib.c:527:5: 
    525.       a->neg = 0;
    526.       a->d[0] = w;
    527. >     a->top = (w ? 1 : 0);
    528.       bn_check_top(a);
    529.       return (1);

crypto/bn/bn_lib.c:529:5: 
    527.       a->top = (w ? 1 : 0);
    528.       bn_check_top(a);
    529. >     return (1);
    530.   }
    531.   

crypto/bn/bn_lib.c:530:1: return from a call to BN_set_word
    528.       bn_check_top(a);
    529.       return (1);
    530. > }
    531.   
    532.   BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)

crypto/bn/bn_ctx.c:284:5: 
  282.       /* OK, make sure the returned bignum is "zero" */
  283.       BN_zero(ret);
  284. >     ctx->used++;
  285.       CTXDBG_RET(ctx, ret);
  286.       return ret;

crypto/bn/bn_ctx.c:286:5: 
  284.       ctx->used++;
  285.       CTXDBG_RET(ctx, ret);
  286. >     return ret;
  287.   }
  288.   

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_gf2m.c:1067:9: Taking false branch
1065.   
1066.       BN_CTX_start(ctx);
1067.       if ((u = BN_CTX_get(ctx)) == NULL)
                ^
1068.           goto err;
1069.   

crypto/bn/bn_gf2m.c:1070:10: 
1068.           goto err;
1069.   
1070. >     if (!BN_set_bit(u, p[0] - 1))
1071.           goto err;
1072.       ret = BN_GF2m_mod_exp_arr(r, a, u, p, ctx);

crypto/bn/bn_lib.c:747:1: start of procedure BN_set_bit()
  745.   }
  746.   
  747. > int BN_set_bit(BIGNUM *a, int n)
  748.   {
  749.       int i, j, k;

crypto/bn/bn_lib.c:751:9: Taking false branch
  749.       int i, j, k;
  750.   
  751.       if (n < 0)
                 ^
  752.           return 0;
  753.   

crypto/bn/bn_lib.c:754:5: 
  752.           return 0;
  753.   
  754. >     i = n / BN_BITS2;
  755.       j = n % BN_BITS2;
  756.       if (a->top <= i) {

crypto/bn/bn_lib.c:755:5: 
  753.   
  754.       i = n / BN_BITS2;
  755. >     j = n % BN_BITS2;
  756.       if (a->top <= i) {
  757.           if (bn_wexpand(a, i + 1) == NULL)

crypto/bn/bn_lib.c:756:9: Taking true branch
  754.       i = n / BN_BITS2;
  755.       j = n % BN_BITS2;
  756.       if (a->top <= i) {
                 ^
  757.           if (bn_wexpand(a, i + 1) == NULL)
  758.               return (0);

crypto/bn/bn_lib.c:757:13: 
  755.       j = n % BN_BITS2;
  756.       if (a->top <= i) {
  757. >         if (bn_wexpand(a, i + 1) == NULL)
  758.               return (0);
  759.           for (k = a->top; k < i + 1; k++)

crypto/bn/bn_lib.c:1071:1: start of procedure bn_wexpand()
    1069.   }
    1070.   
    1071. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1072.   {
    1073.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:1073:13: Condition is true
    1071.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1072.   {
    1073.       return (words <= a->dmax) ? a : bn_expand2(a, words);
                        ^
    1074.   }
    1075.   

crypto/bn/bn_lib.c:1073:12: 
    1071.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1072.   {
    1073. >     return (words <= a->dmax) ? a : bn_expand2(a, words);
    1074.   }
    1075.   

crypto/bn/bn_lib.c:1073:5: 
    1071.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1072.   {
    1073. >     return (words <= a->dmax) ? a : bn_expand2(a, words);
    1074.   }
    1075.   

crypto/bn/bn_lib.c:1074:1: return from a call to bn_wexpand
    1072.   {
    1073.       return (words <= a->dmax) ? a : bn_expand2(a, words);
    1074. > }
    1075.   
    1076.   void bn_correct_top(BIGNUM *a)

crypto/bn/bn_lib.c:757:13: Taking false branch
  755.       j = n % BN_BITS2;
  756.       if (a->top <= i) {
  757.           if (bn_wexpand(a, i + 1) == NULL)
                     ^
  758.               return (0);
  759.           for (k = a->top; k < i + 1; k++)

crypto/bn/bn_lib.c:759:14: 
  757.           if (bn_wexpand(a, i + 1) == NULL)
  758.               return (0);
  759. >         for (k = a->top; k < i + 1; k++)
  760.               a->d[k] = 0;
  761.           a->top = i + 1;

crypto/bn/bn_lib.c:759:26: Loop condition is true. Entering loop body
  757.           if (bn_wexpand(a, i + 1) == NULL)
  758.               return (0);
  759.           for (k = a->top; k < i + 1; k++)
                                  ^
  760.               a->d[k] = 0;
  761.           a->top = i + 1;

crypto/bn/bn_lib.c:760:13: 
  758.               return (0);
  759.           for (k = a->top; k < i + 1; k++)
  760. >             a->d[k] = 0;
  761.           a->top = i + 1;
  762.       }

crypto/bn/bn_lib.c:759:37: 
  757.           if (bn_wexpand(a, i + 1) == NULL)
  758.               return (0);
  759. >         for (k = a->top; k < i + 1; k++)
  760.               a->d[k] = 0;
  761.           a->top = i + 1;

crypto/bn/bn_lib.c:759:26: Loop condition is false. Leaving loop
  757.           if (bn_wexpand(a, i + 1) == NULL)
  758.               return (0);
  759.           for (k = a->top; k < i + 1; k++)
                                  ^
  760.               a->d[k] = 0;
  761.           a->top = i + 1;

crypto/bn/bn_lib.c:761:9: 
  759.           for (k = a->top; k < i + 1; k++)
  760.               a->d[k] = 0;
  761. >         a->top = i + 1;
  762.       }
  763.   

crypto/bn/bn_lib.c:764:5: 
  762.       }
  763.   
  764. >     a->d[i] |= (((BN_ULONG)1) << j);
  765.       bn_check_top(a);
  766.       return (1);

crypto/bn/bn_lib.c:766:5: 
  764.       a->d[i] |= (((BN_ULONG)1) << j);
  765.       bn_check_top(a);
  766. >     return (1);
  767.   }
  768.   

crypto/bn/bn_lib.c:767:1: return from a call to BN_set_bit
  765.       bn_check_top(a);
  766.       return (1);
  767. > }
  768.   
  769.   int BN_clear_bit(BIGNUM *a, int n)

crypto/bn/bn_gf2m.c:1070:10: Taking false branch
1068.           goto err;
1069.   
1070.       if (!BN_set_bit(u, p[0] - 1))
                 ^
1071.           goto err;
1072.       ret = BN_GF2m_mod_exp_arr(r, a, u, p, ctx);

crypto/bn/bn_gf2m.c:1072:5: Skipping BN_GF2m_mod_exp_arr(): empty list of specs
1070.       if (!BN_set_bit(u, p[0] - 1))
1071.           goto err;
1072.       ret = BN_GF2m_mod_exp_arr(r, a, u, p, ctx);
            ^
1073.       bn_check_top(r);
1074.   
