crypto/bn/bn_exp.c:431: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_MONT_CTX_new()` at line 335, column 13 is not reachable after line 431, column 43.
Showing all 30 steps of the trace


crypto/bn/bn_exp.c:299:1: start of procedure BN_mod_exp_mont()
297.   
298.   /* #ifdef MONT_MUL_MOD */
299. > int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx,
300.   	     BN_MONT_CTX *in_mont)
301.   	{

crypto/bn/bn_exp.c:302:2: 
300.   	     BN_MONT_CTX *in_mont)
301.   	{
302. > 	int i,j,bits,ret=0,wstart,wend,window,wvalue;
303.   	int start=1,ts=0;
304.   	BIGNUM *d,*aa,*r;

crypto/bn/bn_exp.c:303:2: 
301.   	{
302.   	int i,j,bits,ret=0,wstart,wend,window,wvalue;
303. > 	int start=1,ts=0;
304.   	BIGNUM *d,*aa,*r;
305.   	BIGNUM val[TABLE_SIZE];

crypto/bn/bn_exp.c:306:2: 
304.   	BIGNUM *d,*aa,*r;
305.   	BIGNUM val[TABLE_SIZE];
306. > 	BN_MONT_CTX *mont=NULL;
307.   
308.   	bn_check_top(a);

crypto/bn/bn_exp.c:312:8: Taking false branch
310.   	bn_check_top(m);
311.   
312.   	if (!(m->d[0] & 1))
              ^
313.   		{
314.   		BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS);

crypto/bn/bn_exp.c:317:2: 
315.   		return(0);
316.   		}
317. > 	d= &(ctx->bn[ctx->tos++]);
318.   	r= &(ctx->bn[ctx->tos++]);
319.   	bits=BN_num_bits(p);

crypto/bn/bn_exp.c:318:2: 
316.   		}
317.   	d= &(ctx->bn[ctx->tos++]);
318. > 	r= &(ctx->bn[ctx->tos++]);
319.   	bits=BN_num_bits(p);
320.   	if (bits == 0)

crypto/bn/bn_exp.c:319:2: 
317.   	d= &(ctx->bn[ctx->tos++]);
318.   	r= &(ctx->bn[ctx->tos++]);
319. > 	bits=BN_num_bits(p);
320.   	if (bits == 0)
321.   		{

crypto/bn/bn_lib.c:238:1: start of procedure BN_num_bits()
  236.   	}
  237.   
  238. > int BN_num_bits(BIGNUM *a)
  239.   	{
  240.   	BN_ULONG l;

crypto/bn/bn_lib.c:245:6: Taking false branch
  243.   	bn_check_top(a);
  244.   
  245.   	if (a->top == 0) return(0);
              ^
  246.   	l=a->d[a->top-1];
  247.   	i=(a->top-1)*BN_BITS2;

crypto/bn/bn_lib.c:246:2: 
  244.   
  245.   	if (a->top == 0) return(0);
  246. > 	l=a->d[a->top-1];
  247.   	i=(a->top-1)*BN_BITS2;
  248.   	if (l == 0)

crypto/bn/bn_lib.c:247:2: 
  245.   	if (a->top == 0) return(0);
  246.   	l=a->d[a->top-1];
  247. > 	i=(a->top-1)*BN_BITS2;
  248.   	if (l == 0)
  249.   		{

crypto/bn/bn_lib.c:248:6: Taking false branch
  246.   	l=a->d[a->top-1];
  247.   	i=(a->top-1)*BN_BITS2;
  248.   	if (l == 0)
              ^
  249.   		{
  250.   #if !defined(NO_STDIO) && !defined(WIN16)

crypto/bn/bn_lib.c:255:2: Skipping BN_num_bits_word(): empty list of specs
  253.   		abort();
  254.   		}
  255.   	return(i+BN_num_bits_word(l));
          ^
  256.   	}
  257.   

crypto/bn/bn_lib.c:256:2: return from a call to BN_num_bits
  254.   		}
  255.   	return(i+BN_num_bits_word(l));
  256.   	}
          ^
  257.   
  258.   void BN_clear_free(BIGNUM *a)

crypto/bn/bn_exp.c:320:6: Taking false branch
318.   	r= &(ctx->bn[ctx->tos++]);
319.   	bits=BN_num_bits(p);
320.   	if (bits == 0)
            ^
321.   		{
322.   		BN_one(r);

crypto/bn/bn_exp.c:330:6: Taking false branch
328.   
329.   #if 1
330.   	if (in_mont != NULL)
            ^
331.   		mont=in_mont;
332.   	else

crypto/bn/bn_exp.c:335:7: 
333.   #endif
334.   		{
335. > 		if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
336.   		if (!BN_MONT_CTX_set(mont,m,ctx)) goto err;
337.   		}

crypto/bn/bn_mont.c:267:1: start of procedure BN_MONT_CTX_new()
  265.   	}
  266.   
  267. > BN_MONT_CTX *BN_MONT_CTX_new(void)
  268.   	{
  269.   	BN_MONT_CTX *ret;

crypto/bn/bn_mont.c:271:6: Taking false branch
  269.   	BN_MONT_CTX *ret;
  270.   
  271.   	if ((ret=(BN_MONT_CTX *)Malloc(sizeof(BN_MONT_CTX))) == NULL)
              ^
  272.   		return(NULL);
  273.   

crypto/bn/bn_mont.c:274:2: Skipping BN_MONT_CTX_init(): empty list of specs
  272.   		return(NULL);
  273.   
  274.   	BN_MONT_CTX_init(ret);
          ^
  275.   	ret->flags=BN_FLG_MALLOCED;
  276.   	return(ret);

crypto/bn/bn_mont.c:275:2: 
  273.   
  274.   	BN_MONT_CTX_init(ret);
  275. > 	ret->flags=BN_FLG_MALLOCED;
  276.   	return(ret);
  277.   	}

crypto/bn/bn_mont.c:276:2: 
  274.   	BN_MONT_CTX_init(ret);
  275.   	ret->flags=BN_FLG_MALLOCED;
  276. > 	return(ret);
  277.   	}
  278.   

crypto/bn/bn_mont.c:277:2: return from a call to BN_MONT_CTX_new
  275.   	ret->flags=BN_FLG_MALLOCED;
  276.   	return(ret);
  277.   	}
          ^
  278.   
  279.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)

crypto/bn/bn_exp.c:335:7: Taking false branch
333.   #endif
334.   		{
335.   		if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
             ^
336.   		if (!BN_MONT_CTX_set(mont,m,ctx)) goto err;
337.   		}

crypto/bn/bn_exp.c:336:8: Taking true branch
334.   		{
335.   		if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
336.   		if (!BN_MONT_CTX_set(mont,m,ctx)) goto err;
              ^
337.   		}
338.   

crypto/bn/bn_exp.c:430:1: 
428.   	BN_from_montgomery(rr,r,mont,ctx);
429.   	ret=1;
430. > err:
431.   	if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
432.   	ctx->tos-=2;

crypto/bn/bn_exp.c:431:7: Taking true branch
429.   	ret=1;
430.   err:
431.   	if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
             ^
432.   	ctx->tos-=2;
433.   	for (i=0; i<ts; i++)

crypto/bn/bn_exp.c:431:28: Taking true branch
429.   	ret=1;
430.   err:
431.   	if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
                                  ^
432.   	ctx->tos-=2;
433.   	for (i=0; i<ts; i++)

crypto/bn/bn_exp.c:431:43: Skipping BN_MONT_CTX_free(): empty list of specs
429.   	ret=1;
430.   err:
431.   	if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
                                                 ^
432.   	ctx->tos-=2;
433.   	for (i=0; i<ts; i++)
