crypto/dh/dh_gen.c:140: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_CTX_new()` at line 95, column 6 is not reachable after line 140, column 19.
Showing all 56 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,char *), char *cb_arg)
88.   	{

crypto/dh/dh_gen.c:89:2: 
87.   	     void (*callback)(int,int,char *), char *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: 
92.   	BN_CTX *ctx=NULL;
93.   
94. > 	ret=DH_new();
95.   	ctx=BN_CTX_new();
96.   	if (ctx == NULL) goto err;

crypto/dh/dh_lib.c:66:1: start of procedure DH_new()
  64.   const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
  65.   
  66. > DH *DH_new(void)
  67.   	{
  68.   	DH *ret;

crypto/dh/dh_lib.c:70:2: 
  68.   	DH *ret;
  69.   
  70. > 	ret=(DH *)Malloc(sizeof(DH));
  71.   	if (ret == NULL)
  72.   		{

crypto/dh/dh_lib.c:71:6: Taking false branch
  69.   
  70.   	ret=(DH *)Malloc(sizeof(DH));
  71.   	if (ret == NULL)
             ^
  72.   		{
  73.   		DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE);

crypto/dh/dh_lib.c:76:2: 
  74.   		return(NULL);
  75.   		}
  76. > 	ret->pad=0;
  77.   	ret->version=0;
  78.   	ret->p=NULL;

crypto/dh/dh_lib.c:77:2: 
  75.   		}
  76.   	ret->pad=0;
  77. > 	ret->version=0;
  78.   	ret->p=NULL;
  79.   	ret->g=NULL;

crypto/dh/dh_lib.c:78:2: 
  76.   	ret->pad=0;
  77.   	ret->version=0;
  78. > 	ret->p=NULL;
  79.   	ret->g=NULL;
  80.   	ret->length=0;

crypto/dh/dh_lib.c:79:2: 
  77.   	ret->version=0;
  78.   	ret->p=NULL;
  79. > 	ret->g=NULL;
  80.   	ret->length=0;
  81.   	ret->pub_key=NULL;

crypto/dh/dh_lib.c:80:2: 
  78.   	ret->p=NULL;
  79.   	ret->g=NULL;
  80. > 	ret->length=0;
  81.   	ret->pub_key=NULL;
  82.   	ret->priv_key=NULL;

crypto/dh/dh_lib.c:81:2: 
  79.   	ret->g=NULL;
  80.   	ret->length=0;
  81. > 	ret->pub_key=NULL;
  82.   	ret->priv_key=NULL;
  83.   	ret->flags=DH_FLAG_CACHE_MONT_P;

crypto/dh/dh_lib.c:82:2: 
  80.   	ret->length=0;
  81.   	ret->pub_key=NULL;
  82. > 	ret->priv_key=NULL;
  83.   	ret->flags=DH_FLAG_CACHE_MONT_P;
  84.   	ret->method_mont_p=NULL;

crypto/dh/dh_lib.c:83:2: 
  81.   	ret->pub_key=NULL;
  82.   	ret->priv_key=NULL;
  83. > 	ret->flags=DH_FLAG_CACHE_MONT_P;
  84.   	ret->method_mont_p=NULL;
  85.   	return(ret);

crypto/dh/dh_lib.c:84:2: 
  82.   	ret->priv_key=NULL;
  83.   	ret->flags=DH_FLAG_CACHE_MONT_P;
  84. > 	ret->method_mont_p=NULL;
  85.   	return(ret);
  86.   	}

crypto/dh/dh_lib.c:85:2: 
  83.   	ret->flags=DH_FLAG_CACHE_MONT_P;
  84.   	ret->method_mont_p=NULL;
  85. > 	return(ret);
  86.   	}
  87.   

crypto/dh/dh_lib.c:86:2: return from a call to DH_new
  84.   	ret->method_mont_p=NULL;
  85.   	return(ret);
  86.   	}
         ^
  87.   
  88.   void DH_free(DH *r)

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

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

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

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

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

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

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

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

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

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

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

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

crypto/dh/dh_gen.c:130:2: 
128.   	if (callback != NULL) callback(3,0,cb_arg);
129.   	ret->p=p;
130. > 	ret->g=BN_new();
131.   	if (!BN_set_word(ret->g,g)) goto err;
132.   	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:131:7: Taking false branch
129.   	ret->p=p;
130.   	ret->g=BN_new();
131.   	if (!BN_set_word(ret->g,g)) goto err;
             ^
132.   	ok=1;
133.   err:

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

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

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

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

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

DH *DH_generate_parameters(int prime_len, int generator,
	     void (*callback)(int,int,char *), char *cb_arg)
	{
	BIGNUM *p=NULL,*t1,*t2;
	DH *ret=NULL;
	int g,ok= -1;
	BN_CTX *ctx=NULL;
	ret=DH_new();
	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,char *), char *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\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}', 'DH *DH_new(void)\n\t{\n\tDH *ret;\n\tret=(DH *)Malloc(sizeof(DH));\n\tif (ret == NULL)\n\t\t{\n\t\tDHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n\tret->pad=0;\n\tret->version=0;\n\tret->p=NULL;\n\tret->g=NULL;\n\tret->length=0;\n\tret->pub_key=NULL;\n\tret->priv_key=NULL;\n\tret->flags=DH_FLAG_CACHE_MONT_P;\n\tret->method_mont_p=NULL;\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}']