crypto/rsa/rsa_eay.c:395: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_CTX_new()` at line 345, column 6 is not reachable after line 395, column 19.
Showing all 44 steps of the trace


crypto/rsa/rsa_eay.c:334:1: start of procedure RSA_eay_public_decrypt()
332.   	}
333.   
334. > static int RSA_eay_public_decrypt(int flen, unsigned char *from,
335.   	     unsigned char *to, RSA *rsa, int padding)
336.   	{

crypto/rsa/rsa_eay.c:338:2: 
336.   	{
337.   	BIGNUM f,ret;
338. > 	int i,num=0,r= -1;
339.   	unsigned char *p;
340.   	unsigned char *buf=NULL;

crypto/rsa/rsa_eay.c:340:2: 
338.   	int i,num=0,r= -1;
339.   	unsigned char *p;
340. > 	unsigned char *buf=NULL;
341.   	BN_CTX *ctx=NULL;
342.   

crypto/rsa/rsa_eay.c:341:2: 
339.   	unsigned char *p;
340.   	unsigned char *buf=NULL;
341. > 	BN_CTX *ctx=NULL;
342.   
343.   	BN_init(&f);

crypto/rsa/rsa_eay.c:343:2: 
341.   	BN_CTX *ctx=NULL;
342.   
343. > 	BN_init(&f);
344.   	BN_init(&ret);
345.   	ctx=BN_CTX_new();

crypto/bn/bn_lib.c:285:1: start of procedure BN_init()
  283.   	}
  284.   
  285. > void BN_init(BIGNUM *a)
  286.   	{
  287.   	memset(a,0,sizeof(BIGNUM));

crypto/bn/bn_lib.c:287:2: 
  285.   void BN_init(BIGNUM *a)
  286.   	{
  287. > 	memset(a,0,sizeof(BIGNUM));
  288.   	}
  289.   

crypto/bn/bn_lib.c:288:2: return from a call to BN_init
  286.   	{
  287.   	memset(a,0,sizeof(BIGNUM));
  288.   	}
          ^
  289.   
  290.   BIGNUM *BN_new(void)

crypto/rsa/rsa_eay.c:344:2: 
342.   
343.   	BN_init(&f);
344. > 	BN_init(&ret);
345.   	ctx=BN_CTX_new();
346.   	if (ctx == NULL) goto err;

crypto/bn/bn_lib.c:285:1: start of procedure BN_init()
  283.   	}
  284.   
  285. > void BN_init(BIGNUM *a)
  286.   	{
  287.   	memset(a,0,sizeof(BIGNUM));

crypto/bn/bn_lib.c:287:2: 
  285.   void BN_init(BIGNUM *a)
  286.   	{
  287. > 	memset(a,0,sizeof(BIGNUM));
  288.   	}
  289.   

crypto/bn/bn_lib.c:288:2: return from a call to BN_init
  286.   	{
  287.   	memset(a,0,sizeof(BIGNUM));
  288.   	}
          ^
  289.   
  290.   BIGNUM *BN_new(void)

crypto/rsa/rsa_eay.c:345:2: 
343.   	BN_init(&f);
344.   	BN_init(&ret);
345. > 	ctx=BN_CTX_new();
346.   	if (ctx == NULL) goto err;
347.   

crypto/bn/bn_lib.c:308:1: start of procedure BN_CTX_new()
  306.   
  307.   
  308. > BN_CTX *BN_CTX_new(void)
  309.   	{
  310.   	BN_CTX *ret;

crypto/bn/bn_lib.c:312:2: 
  310.   	BN_CTX *ret;
  311.   
  312. > 	ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
  313.   	if (ret == NULL)
  314.   		{

crypto/bn/bn_lib.c:313:6: Taking false branch
  311.   
  312.   	ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
  313.   	if (ret == NULL)
              ^
  314.   		{
  315.   		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:319:2: Skipping BN_CTX_init(): empty list of specs
  317.   		}
  318.   
  319.   	BN_CTX_init(ret);
          ^
  320.   	ret->flags=BN_FLG_MALLOCED;
  321.   	return(ret);

crypto/bn/bn_lib.c:320:2: 
  318.   
  319.   	BN_CTX_init(ret);
  320. > 	ret->flags=BN_FLG_MALLOCED;
  321.   	return(ret);
  322.   	}

crypto/bn/bn_lib.c:321:2: 
  319.   	BN_CTX_init(ret);
  320.   	ret->flags=BN_FLG_MALLOCED;
  321. > 	return(ret);
  322.   	}
  323.   

crypto/bn/bn_lib.c:322:2: return from a call to BN_CTX_new
  320.   	ret->flags=BN_FLG_MALLOCED;
  321.   	return(ret);
  322.   	}
          ^
  323.   
  324.   void BN_CTX_init(BN_CTX *ctx)

crypto/rsa/rsa_eay.c:346:6: Taking false branch
344.   	BN_init(&ret);
345.   	ctx=BN_CTX_new();
346.   	if (ctx == NULL) goto err;
            ^
347.   
348.   	num=BN_num_bytes(rsa->n);

crypto/rsa/rsa_eay.c:348:2: 
346.   	if (ctx == NULL) goto err;
347.   
348. > 	num=BN_num_bytes(rsa->n);
349.   	buf=(unsigned char *)Malloc(num);
350.   	if (buf == NULL)

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 true 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:245:19: 
  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: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/rsa/rsa_eay.c:349:2: 
347.   
348.   	num=BN_num_bytes(rsa->n);
349. > 	buf=(unsigned char *)Malloc(num);
350.   	if (buf == NULL)
351.   		{

crypto/rsa/rsa_eay.c:350:6: Taking false branch
348.   	num=BN_num_bytes(rsa->n);
349.   	buf=(unsigned char *)Malloc(num);
350.   	if (buf == NULL)
            ^
351.   		{
352.   		RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,ERR_R_MALLOC_FAILURE);

crypto/rsa/rsa_eay.c:358:6: Taking false branch
356.   	/* This check was for equallity but PGP does evil things
357.   	 * and chops off the top '0' bytes */
358.   	if (flen > num)
            ^
359.   		{
360.   		RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_DATA_GREATER_THAN_MOD_LEN);

crypto/rsa/rsa_eay.c:364:6: Taking false branch
362.   		}
363.   
364.   	if (BN_bin2bn(from,flen,&f) == NULL) goto err;
            ^
365.   	/* do the decrypt */
366.   	if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))

crypto/rsa/rsa_eay.c:366:7: Taking true branch
364.   	if (BN_bin2bn(from,flen,&f) == NULL) goto err;
365.   	/* do the decrypt */
366.   	if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))
             ^
367.   		{
368.   		if ((rsa->_method_mod_n=BN_MONT_CTX_new()) != NULL)

crypto/rsa/rsa_eay.c:366:39: Taking true branch
364.   	if (BN_bin2bn(from,flen,&f) == NULL) goto err;
365.   	/* do the decrypt */
366.   	if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))
                                             ^
367.   		{
368.   		if ((rsa->_method_mod_n=BN_MONT_CTX_new()) != NULL)

crypto/rsa/rsa_eay.c:368:7: 
366.   	if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))
367.   		{
368. > 		if ((rsa->_method_mod_n=BN_MONT_CTX_new()) != NULL)
369.   			if (!BN_MONT_CTX_set(rsa->_method_mod_n,rsa->n,ctx))
370.   			    goto err;

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/rsa/rsa_eay.c:368:7: Taking true branch
366.   	if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))
367.   		{
368.   		if ((rsa->_method_mod_n=BN_MONT_CTX_new()) != NULL)
             ^
369.   			if (!BN_MONT_CTX_set(rsa->_method_mod_n,rsa->n,ctx))
370.   			    goto err;

crypto/rsa/rsa_eay.c:369:9: Taking true branch
367.   		{
368.   		if ((rsa->_method_mod_n=BN_MONT_CTX_new()) != NULL)
369.   			if (!BN_MONT_CTX_set(rsa->_method_mod_n,rsa->n,ctx))
               ^
370.   			    goto err;
371.   		}

crypto/rsa/rsa_eay.c:394:1: 
392.   		RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_PADDING_CHECK_FAILED);
393.   
394. > err:
395.   	if (ctx != NULL) BN_CTX_free(ctx);
396.   	BN_clear_free(&f);

crypto/rsa/rsa_eay.c:395:6: Taking true branch
393.   
394.   err:
395.   	if (ctx != NULL) BN_CTX_free(ctx);
            ^
396.   	BN_clear_free(&f);
397.   	BN_clear_free(&ret);

crypto/rsa/rsa_eay.c:395:19: Skipping BN_CTX_free(): empty list of specs
393.   
394.   err:
395.   	if (ctx != NULL) BN_CTX_free(ctx);
                         ^
396.   	BN_clear_free(&f);
397.   	BN_clear_free(&ret);
