crypto/dh/dh_gen.c:141: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_CTX_new()` at line 96, column 6 is not reachable after line 141, column 19.
Showing all 43 steps of the trace


crypto/dh/dh_gen.c:86:1: start of procedure DH_generate_parameters()
84.    */
85.   
86. > DH *DH_generate_parameters(int prime_len, int generator,
87.   	     void (*callback)(int,int,void *), void *cb_arg)
88.   	{

crypto/dh/dh_gen.c:89:2: 
87.   	     void (*callback)(int,int,void *), void *cb_arg)
88.   	{
89. > 	BIGNUM *p=NULL,*t1,*t2;
90.   	DH *ret=NULL;
91.   	int g,ok= -1;

crypto/dh/dh_gen.c:90:2: 
88.   	{
89.   	BIGNUM *p=NULL,*t1,*t2;
90. > 	DH *ret=NULL;
91.   	int g,ok= -1;
92.   	BN_CTX *ctx=NULL;

crypto/dh/dh_gen.c:91:2: 
89.   	BIGNUM *p=NULL,*t1,*t2;
90.   	DH *ret=NULL;
91. > 	int g,ok= -1;
92.   	BN_CTX *ctx=NULL;
93.   

crypto/dh/dh_gen.c:92:2: 
90.   	DH *ret=NULL;
91.   	int g,ok= -1;
92. > 	BN_CTX *ctx=NULL;
93.   
94.   	ret=DH_new();

crypto/dh/dh_gen.c:94:2: Skipping DH_new(): empty list of specs
92.   	BN_CTX *ctx=NULL;
93.   
94.   	ret=DH_new();
       ^
95.   	if (ret == NULL) goto err;
96.   	ctx=BN_CTX_new();

crypto/dh/dh_gen.c:95:6: Taking false branch
93.   
94.   	ret=DH_new();
95.   	if (ret == NULL) goto err;
           ^
96.   	ctx=BN_CTX_new();
97.   	if (ctx == NULL) goto err;

crypto/dh/dh_gen.c:96:2: 
94.   	ret=DH_new();
95.   	if (ret == NULL) goto err;
96. > 	ctx=BN_CTX_new();
97.   	if (ctx == NULL) goto err;
98.   	t1= &(ctx->bn[0]);

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/dh/dh_gen.c:97:6: Taking false branch
95.   	if (ret == NULL) goto err;
96.   	ctx=BN_CTX_new();
97.   	if (ctx == NULL) goto err;
            ^
98.   	t1= &(ctx->bn[0]);
99.   	t2= &(ctx->bn[1]);

crypto/dh/dh_gen.c:98:2: 
96.   	ctx=BN_CTX_new();
97.   	if (ctx == NULL) goto err;
98. > 	t1= &(ctx->bn[0]);
99.   	t2= &(ctx->bn[1]);
100.   	ctx->tos=2;

crypto/dh/dh_gen.c:99:2: 
97.   	if (ctx == NULL) goto err;
98.   	t1= &(ctx->bn[0]);
99. > 	t2= &(ctx->bn[1]);
100.   	ctx->tos=2;
101.   	

crypto/dh/dh_gen.c:100:2: 
98.   	t1= &(ctx->bn[0]);
99.   	t2= &(ctx->bn[1]);
100. > 	ctx->tos=2;
101.   	
102.   	if (generator == DH_GENERATOR_2)

crypto/dh/dh_gen.c:102:6: Taking false branch
100.   	ctx->tos=2;
101.   	
102.   	if (generator == DH_GENERATOR_2)
            ^
103.   		{
104.   		BN_set_word(t1,24);

crypto/dh/dh_gen.c:116:11: Taking false branch
114.   		}
115.   #endif
116.   	else if (generator == DH_GENERATOR_5)
                 ^
117.   		{
118.   		BN_set_word(t1,10);

crypto/dh/dh_gen.c:125:3: 
123.   		}
124.   	else
125. > 		g=generator;
126.   	
127.   	p=BN_generate_prime(NULL,prime_len,1,t1,t2,callback,cb_arg);

crypto/dh/dh_gen.c:127:2: Skipping BN_generate_prime(): empty list of specs
125.   		g=generator;
126.   	
127.   	p=BN_generate_prime(NULL,prime_len,1,t1,t2,callback,cb_arg);
        ^
128.   	if (p == NULL) goto err;
129.   	if (callback != NULL) callback(3,0,cb_arg);

crypto/dh/dh_gen.c:128:6: Taking false branch
126.   	
127.   	p=BN_generate_prime(NULL,prime_len,1,t1,t2,callback,cb_arg);
128.   	if (p == NULL) goto err;
            ^
129.   	if (callback != NULL) callback(3,0,cb_arg);
130.   	ret->p=p;

crypto/dh/dh_gen.c:129:6: Taking true branch
127.   	p=BN_generate_prime(NULL,prime_len,1,t1,t2,callback,cb_arg);
128.   	if (p == NULL) goto err;
129.   	if (callback != NULL) callback(3,0,cb_arg);
            ^
130.   	ret->p=p;
131.   	ret->g=BN_new();

crypto/dh/dh_gen.c:129:24: Skipping __function_pointer__(): unresolved function pointer
127.   	p=BN_generate_prime(NULL,prime_len,1,t1,t2,callback,cb_arg);
128.   	if (p == NULL) goto err;
129.   	if (callback != NULL) callback(3,0,cb_arg);
                              ^
130.   	ret->p=p;
131.   	ret->g=BN_new();

crypto/dh/dh_gen.c:130:2: 
128.   	if (p == NULL) goto err;
129.   	if (callback != NULL) callback(3,0,cb_arg);
130. > 	ret->p=p;
131.   	ret->g=BN_new();
132.   	if (!BN_set_word(ret->g,g)) goto err;

crypto/dh/dh_gen.c:131:2: 
129.   	if (callback != NULL) callback(3,0,cb_arg);
130.   	ret->p=p;
131. > 	ret->g=BN_new();
132.   	if (!BN_set_word(ret->g,g)) goto err;
133.   	ok=1;

crypto/bn/bn_lib.c:290:1: start of procedure BN_new()
  288.   	}
  289.   
  290. > BIGNUM *BN_new(void)
  291.   	{
  292.   	BIGNUM *ret;

crypto/bn/bn_lib.c:294:6: Taking false branch
  292.   	BIGNUM *ret;
  293.   
  294.   	if ((ret=(BIGNUM *)Malloc(sizeof(BIGNUM))) == NULL)
              ^
  295.   		{
  296.   		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:299:2: 
  297.   		return(NULL);
  298.   		}
  299. > 	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301.   	ret->neg=0;

crypto/bn/bn_lib.c:300:2: 
  298.   		}
  299.   	ret->flags=BN_FLG_MALLOCED;
  300. > 	ret->top=0;
  301.   	ret->neg=0;
  302.   	ret->max=0;

crypto/bn/bn_lib.c:301:2: 
  299.   	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301. > 	ret->neg=0;
  302.   	ret->max=0;
  303.   	ret->d=NULL;

crypto/bn/bn_lib.c:302:2: 
  300.   	ret->top=0;
  301.   	ret->neg=0;
  302. > 	ret->max=0;
  303.   	ret->d=NULL;
  304.   	return(ret);

crypto/bn/bn_lib.c:303:2: 
  301.   	ret->neg=0;
  302.   	ret->max=0;
  303. > 	ret->d=NULL;
  304.   	return(ret);
  305.   	}

crypto/bn/bn_lib.c:304:2: 
  302.   	ret->max=0;
  303.   	ret->d=NULL;
  304. > 	return(ret);
  305.   	}
  306.   

crypto/bn/bn_lib.c:305:2: return from a call to BN_new
  303.   	ret->d=NULL;
  304.   	return(ret);
  305.   	}
          ^
  306.   
  307.   

crypto/dh/dh_gen.c:132:7: Taking false branch
130.   	ret->p=p;
131.   	ret->g=BN_new();
132.   	if (!BN_set_word(ret->g,g)) goto err;
             ^
133.   	ok=1;
134.   err:

crypto/dh/dh_gen.c:133:2: 
131.   	ret->g=BN_new();
132.   	if (!BN_set_word(ret->g,g)) goto err;
133. > 	ok=1;
134.   err:
135.   	if (ok == -1)

crypto/dh/dh_gen.c:134:1: 
132.   	if (!BN_set_word(ret->g,g)) goto err;
133.   	ok=1;
134. > err:
135.   	if (ok == -1)
136.   		{

crypto/dh/dh_gen.c:135:6: Taking false branch
133.   	ok=1;
134.   err:
135.   	if (ok == -1)
            ^
136.   		{
137.   		DHerr(DH_F_DH_GENERATE_PARAMETERS,ERR_R_BN_LIB);

crypto/dh/dh_gen.c:141:6: Taking true branch
139.   		}
140.   
141.   	if (ctx != NULL) BN_CTX_free(ctx);
            ^
142.   	if (!ok && (ret != NULL))
143.   		{

crypto/dh/dh_gen.c:141:19: Skipping BN_CTX_free(): empty list of specs
139.   		}
140.   
141.   	if (ctx != NULL) BN_CTX_free(ctx);
                         ^
142.   	if (!ok && (ret != NULL))
143.   		{

DH *DH_generate_parameters(int prime_len, int generator,
	     void (*callback)(int,int,void *), void *cb_arg)
	{
	BIGNUM *p=NULL,*t1,*t2;
	DH *ret=NULL;
	int g,ok= -1;
	BN_CTX *ctx=NULL;
	ret=DH_new();
	if (ret == NULL) goto err;
	ctx=BN_CTX_new();
	if (ctx == NULL) goto err;
	t1= &(ctx->bn[0]);
	t2= &(ctx->bn[1]);
	ctx->tos=2;
	if (generator == DH_GENERATOR_2)
		{
		BN_set_word(t1,24);
		BN_set_word(t2,11);
		g=2;
		}
#ifdef undef
	else if (generator == DH_GENERATOR_3)
		{
		BN_set_word(t1,12);
		BN_set_word(t2,5);
		g=3;
		}
#endif
	else if (generator == DH_GENERATOR_5)
		{
		BN_set_word(t1,10);
		BN_set_word(t2,3);
		g=5;
		}
	else
		g=generator;
	p=BN_generate_prime(NULL,prime_len,1,t1,t2,callback,cb_arg);
	if (p == NULL) goto err;
	if (callback != NULL) callback(3,0,cb_arg);
	ret->p=p;
	ret->g=BN_new();
	if (!BN_set_word(ret->g,g)) goto err;
	ok=1;
err:
	if (ok == -1)
		{
		DHerr(DH_F_DH_GENERATE_PARAMETERS,ERR_R_BN_LIB);
		ok=0;
		}
	if (ctx != NULL) BN_CTX_free(ctx);
	if (!ok && (ret != NULL))
		{
		DH_free(ret);
		ret=NULL;
		}
	return(ret);
	}
['DH *DH_generate_parameters(int prime_len, int generator,\n\t     void (*callback)(int,int,void *), void *cb_arg)\n\t{\n\tBIGNUM *p=NULL,*t1,*t2;\n\tDH *ret=NULL;\n\tint g,ok= -1;\n\tBN_CTX *ctx=NULL;\n\tret=DH_new();\n\tif (ret == NULL) goto err;\n\tctx=BN_CTX_new();\n\tif (ctx == NULL) goto err;\n\tt1= &(ctx->bn[0]);\n\tt2= &(ctx->bn[1]);\n\tctx->tos=2;\n\tif (generator == DH_GENERATOR_2)\n\t\t{\n\t\tBN_set_word(t1,24);\n\t\tBN_set_word(t2,11);\n\t\tg=2;\n\t\t}\n#ifdef undef\n\telse if (generator == DH_GENERATOR_3)\n\t\t{\n\t\tBN_set_word(t1,12);\n\t\tBN_set_word(t2,5);\n\t\tg=3;\n\t\t}\n#endif\n\telse if (generator == DH_GENERATOR_5)\n\t\t{\n\t\tBN_set_word(t1,10);\n\t\tBN_set_word(t2,3);\n\t\tg=5;\n\t\t}\n\telse\n\t\tg=generator;\n\tp=BN_generate_prime(NULL,prime_len,1,t1,t2,callback,cb_arg);\n\tif (p == NULL) goto err;\n\tif (callback != NULL) callback(3,0,cb_arg);\n\tret->p=p;\n\tret->g=BN_new();\n\tif (!BN_set_word(ret->g,g)) goto err;\n\tok=1;\nerr:\n\tif (ok == -1)\n\t\t{\n\t\tDHerr(DH_F_DH_GENERATE_PARAMETERS,ERR_R_BN_LIB);\n\t\tok=0;\n\t\t}\n\tif (ctx != NULL) BN_CTX_free(ctx);\n\tif (!ok && (ret != NULL))\n\t\t{\n\t\tDH_free(ret);\n\t\tret=NULL;\n\t\t}\n\treturn(ret);\n\t}', 'BN_CTX *BN_CTX_new(void)\n\t{\n\tBN_CTX *ret;\n\tret=(BN_CTX *)Malloc(sizeof(BN_CTX));\n\tif (ret == NULL)\n\t\t{\n\t\tBNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n\tBN_CTX_init(ret);\n\tret->flags=BN_FLG_MALLOCED;\n\treturn(ret);\n\t}', 'BIGNUM *BN_new(void)\n\t{\n\tBIGNUM *ret;\n\tif ((ret=(BIGNUM *)Malloc(sizeof(BIGNUM))) == NULL)\n\t\t{\n\t\tBNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n\tret->flags=BN_FLG_MALLOCED;\n\tret->top=0;\n\tret->neg=0;\n\tret->max=0;\n\tret->d=NULL;\n\treturn(ret);\n\t}']