crypto/dsa/dsa_ossl.c:259: error: NULL_DEREFERENCE
  pointer `ctx` last assigned on line 218 could be null and is dereferenced by call to `BN_CTX_free()` at line 259, column 22.
Showing all 63 steps of the trace


crypto/dsa/dsa_ossl.c:202:1: start of procedure dsa_sign_setup()
200.   	}
201.   
202. > static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
203.   	{
204.   	BN_CTX *ctx;

crypto/dsa/dsa_ossl.c:205:2: 
203.   	{
204.   	BN_CTX *ctx;
205. > 	BIGNUM k,*kinv=NULL,*r=NULL;
206.   	int ret=0;
207.   

crypto/dsa/dsa_ossl.c:206:2: 
204.   	BN_CTX *ctx;
205.   	BIGNUM k,*kinv=NULL,*r=NULL;
206. > 	int ret=0;
207.   
208.   	if (!dsa->p || !dsa->q || !dsa->g)

crypto/dsa/dsa_ossl.c:208:7: Taking false branch
206.   	int ret=0;
207.   
208.   	if (!dsa->p || !dsa->q || !dsa->g)
             ^
209.   		{
210.   		DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS);

crypto/dsa/dsa_ossl.c:208:18: Taking false branch
206.   	int ret=0;
207.   
208.   	if (!dsa->p || !dsa->q || !dsa->g)
                        ^
209.   		{
210.   		DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS);

crypto/dsa/dsa_ossl.c:208:29: Taking false branch
206.   	int ret=0;
207.   
208.   	if (!dsa->p || !dsa->q || !dsa->g)
                                   ^
209.   		{
210.   		DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS);

crypto/dsa/dsa_ossl.c:214:2: 
212.   		}
213.   
214. > 	BN_init(&k);
215.   
216.   	if (ctx_in == NULL)

crypto/bn/bn_lib.c:289:1: start of procedure BN_init()
  287.   	}
  288.   
  289. > void BN_init(BIGNUM *a)
  290.   	{
  291.   	memset(a,0,sizeof(BIGNUM));

crypto/bn/bn_lib.c:291:2: 
  289.   void BN_init(BIGNUM *a)
  290.   	{
  291. > 	memset(a,0,sizeof(BIGNUM));
  292.   	bn_check_top(a);
  293.   	}

crypto/bn/bn_lib.c:293:2: return from a call to BN_init
  291.   	memset(a,0,sizeof(BIGNUM));
  292.   	bn_check_top(a);
  293.   	}
          ^
  294.   
  295.   BIGNUM *BN_new(void)

crypto/dsa/dsa_ossl.c:216:6: Taking true branch
214.   	BN_init(&k);
215.   
216.   	if (ctx_in == NULL)
            ^
217.   		{
218.   		if ((ctx=BN_CTX_new()) == NULL) goto err;

crypto/dsa/dsa_ossl.c:218:7: 
216.   	if (ctx_in == NULL)
217.   		{
218. > 		if ((ctx=BN_CTX_new()) == NULL) goto err;
219.   		}
220.   	else

crypto/bn/bn_ctx.c:217:1: start of procedure BN_CTX_new()
  215.   #endif
  216.   
  217. > BN_CTX *BN_CTX_new(void)
  218.   	{
  219.   	BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));

crypto/bn/bn_ctx.c:219:2: 
  217.   BN_CTX *BN_CTX_new(void)
  218.   	{
  219. > 	BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));
  220.   	if(!ret)
  221.   		{

crypto/mem.c:291:1: start of procedure CRYPTO_malloc()
    289.   	}
    290.   
    291. > void *CRYPTO_malloc(int num, const char *file, int line)
    292.   	{
    293.   	void *ret = NULL;

crypto/mem.c:293:2: 
    291.   void *CRYPTO_malloc(int num, const char *file, int line)
    292.   	{
    293. > 	void *ret = NULL;
    294.   	extern unsigned char cleanse_ctr;
    295.   

crypto/mem.c:296:6: Taking false branch
    294.   	extern unsigned char cleanse_ctr;
    295.   
    296.   	if (num <= 0) return NULL;
                ^
    297.   
    298.   	allow_customize = 0;

crypto/mem.c:298:2: 
    296.   	if (num <= 0) return NULL;
    297.   
    298. > 	allow_customize = 0;
    299.   	if (malloc_debug_func != NULL)
    300.   		{

crypto/mem.c:299:6: Taking true branch
    297.   
    298.   	allow_customize = 0;
    299.   	if (malloc_debug_func != NULL)
                ^
    300.   		{
    301.   		allow_customize_debug = 0;

crypto/mem.c:301:3: 
    299.   	if (malloc_debug_func != NULL)
    300.   		{
    301. > 		allow_customize_debug = 0;
    302.   		malloc_debug_func(NULL, num, file, line, 0);
    303.   		}

crypto/mem.c:302:3: Skipping __function_pointer__(): unresolved function pointer
    300.   		{
    301.   		allow_customize_debug = 0;
    302.   		malloc_debug_func(NULL, num, file, line, 0);
             ^
    303.   		}
    304.   	ret = malloc_ex_func(num,file,line);

crypto/mem.c:304:2: Skipping __function_pointer__(): unresolved function pointer
    302.   		malloc_debug_func(NULL, num, file, line, 0);
    303.   		}
    304.   	ret = malloc_ex_func(num,file,line);
            ^
    305.   #ifdef LEVITTE_DEBUG_MEM
    306.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);

crypto/mem.c:308:6: Taking true branch
    306.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
    307.   #endif
    308.   	if (malloc_debug_func != NULL)
                ^
    309.   		malloc_debug_func(ret, num, file, line, 1);
    310.   

crypto/mem.c:309:3: Skipping __function_pointer__(): unresolved function pointer
    307.   #endif
    308.   	if (malloc_debug_func != NULL)
    309.   		malloc_debug_func(ret, num, file, line, 1);
             ^
    310.   
    311.           /* Create a dependency on the value of 'cleanse_ctr' so our memory

crypto/mem.c:314:12: Taking false branch
    312.            * sanitisation function can't be optimised out. NB: We only do
    313.            * this for >2Kb so the overhead doesn't bother us. */
    314.           if(ret && (num > 2048))
                      ^
    315.                   ((unsigned char *)ret)[0] = cleanse_ctr;
    316.   

crypto/mem.c:317:2: 
    315.                   ((unsigned char *)ret)[0] = cleanse_ctr;
    316.   
    317. > 	return ret;
    318.   	}
    319.   

crypto/mem.c:318:2: return from a call to CRYPTO_malloc
    316.   
    317.   	return ret;
    318.   	}
            ^
    319.   
    320.   void *CRYPTO_realloc(void *str, int num, const char *file, int line)

crypto/bn/bn_ctx.c:220:6: Taking true branch
  218.   	{
  219.   	BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));
  220.   	if(!ret)
              ^
  221.   		{
  222.   		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_ctx.c:222:3: 
  220.   	if(!ret)
  221.   		{
  222. > 		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
  223.   		return NULL;
  224.   		}

crypto/err/err.c:664:1: start of procedure ERR_put_error()
    662.   /********************************************************/
    663.   
    664. > void ERR_put_error(int lib, int func, int reason, const char *file,
    665.   	     int line)
    666.   	{

crypto/err/err.c:688:2: Skipping ERR_get_state(): empty list of specs
    686.   	}
    687.   #endif
    688.   	es=ERR_get_state();
            ^
    689.   
    690.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:690:2: 
    688.   	es=ERR_get_state();
    689.   
    690. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    691.   	if (es->top == es->bottom)
    692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:691:6: Taking false branch
    689.   
    690.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    691.   	if (es->top == es->bottom)
                ^
    692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    693.   	es->err_flags[es->top]=0;

crypto/err/err.c:693:2: 
    691.   	if (es->top == es->bottom)
    692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    693. > 	es->err_flags[es->top]=0;
    694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    695.   	es->err_file[es->top]=file;

crypto/err/err.c:694:2: 
    692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    693.   	es->err_flags[es->top]=0;
    694. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    695.   	es->err_file[es->top]=file;
    696.   	es->err_line[es->top]=line;

crypto/err/err.c:695:2: 
    693.   	es->err_flags[es->top]=0;
    694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    695. > 	es->err_file[es->top]=file;
    696.   	es->err_line[es->top]=line;
    697.   	err_clear_data(es,es->top);

crypto/err/err.c:696:2: 
    694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    695.   	es->err_file[es->top]=file;
    696. > 	es->err_line[es->top]=line;
    697.   	err_clear_data(es,es->top);
    698.   	}

crypto/err/err.c:697:2: Taking true branch
    695.   	es->err_file[es->top]=file;
    696.   	es->err_line[es->top]=line;
    697.   	err_clear_data(es,es->top);
            ^
    698.   	}
    699.   

crypto/err/err.c:697:2: Taking false branch
    695.   	es->err_file[es->top]=file;
    696.   	es->err_line[es->top]=line;
    697.   	err_clear_data(es,es->top);
            ^
    698.   	}
    699.   

crypto/err/err.c:697:2: Loop condition is false. Leaving loop
    695.   	es->err_file[es->top]=file;
    696.   	es->err_line[es->top]=line;
    697.   	err_clear_data(es,es->top);
            ^
    698.   	}
    699.   

crypto/err/err.c:698:2: return from a call to ERR_put_error
    696.   	es->err_line[es->top]=line;
    697.   	err_clear_data(es,es->top);
    698.   	}
            ^
    699.   
    700.   void ERR_clear_error(void)

crypto/bn/bn_ctx.c:223:3: 
  221.   		{
  222.   		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
  223. > 		return NULL;
  224.   		}
  225.   	/* Initialise the structure */

crypto/bn/bn_ctx.c:232:2: return from a call to BN_CTX_new
  230.   	ret->too_many = 0;
  231.   	return ret;
  232.   	}
          ^
  233.   
  234.   void BN_CTX_free(BN_CTX *ctx)

crypto/dsa/dsa_ossl.c:218:7: Taking true branch
216.   	if (ctx_in == NULL)
217.   		{
218.   		if ((ctx=BN_CTX_new()) == NULL) goto err;
             ^
219.   		}
220.   	else

crypto/dsa/dsa_ossl.c:252:1: 
250.   	*rp=r;
251.   	ret=1;
252. > err:
253.   	if (!ret)
254.   		{

crypto/dsa/dsa_ossl.c:253:7: Taking true branch
251.   	ret=1;
252.   err:
253.   	if (!ret)
             ^
254.   		{
255.   		DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);

crypto/dsa/dsa_ossl.c:255:3: 
253.   	if (!ret)
254.   		{
255. > 		DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);
256.   		if (kinv != NULL) BN_clear_free(kinv);
257.   		if (r != NULL) BN_clear_free(r);

crypto/err/err.c:664:1: start of procedure ERR_put_error()
  662.   /********************************************************/
  663.   
  664. > void ERR_put_error(int lib, int func, int reason, const char *file,
  665.   	     int line)
  666.   	{

crypto/err/err.c:688:2: Skipping ERR_get_state(): empty list of specs
  686.   	}
  687.   #endif
  688.   	es=ERR_get_state();
          ^
  689.   
  690.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:690:2: 
  688.   	es=ERR_get_state();
  689.   
  690. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
  691.   	if (es->top == es->bottom)
  692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:691:6: Taking false branch
  689.   
  690.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
  691.   	if (es->top == es->bottom)
              ^
  692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
  693.   	es->err_flags[es->top]=0;

crypto/err/err.c:693:2: 
  691.   	if (es->top == es->bottom)
  692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
  693. > 	es->err_flags[es->top]=0;
  694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
  695.   	es->err_file[es->top]=file;

crypto/err/err.c:694:2: 
  692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
  693.   	es->err_flags[es->top]=0;
  694. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
  695.   	es->err_file[es->top]=file;
  696.   	es->err_line[es->top]=line;

crypto/err/err.c:695:2: 
  693.   	es->err_flags[es->top]=0;
  694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
  695. > 	es->err_file[es->top]=file;
  696.   	es->err_line[es->top]=line;
  697.   	err_clear_data(es,es->top);

crypto/err/err.c:696:2: 
  694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
  695.   	es->err_file[es->top]=file;
  696. > 	es->err_line[es->top]=line;
  697.   	err_clear_data(es,es->top);
  698.   	}

crypto/err/err.c:697:2: Taking true branch
  695.   	es->err_file[es->top]=file;
  696.   	es->err_line[es->top]=line;
  697.   	err_clear_data(es,es->top);
          ^
  698.   	}
  699.   

crypto/err/err.c:697:2: Taking false branch
  695.   	es->err_file[es->top]=file;
  696.   	es->err_line[es->top]=line;
  697.   	err_clear_data(es,es->top);
          ^
  698.   	}
  699.   

crypto/err/err.c:697:2: Loop condition is false. Leaving loop
  695.   	es->err_file[es->top]=file;
  696.   	es->err_line[es->top]=line;
  697.   	err_clear_data(es,es->top);
          ^
  698.   	}
  699.   

crypto/err/err.c:698:2: return from a call to ERR_put_error
  696.   	es->err_line[es->top]=line;
  697.   	err_clear_data(es,es->top);
  698.   	}
          ^
  699.   
  700.   void ERR_clear_error(void)

crypto/dsa/dsa_ossl.c:256:7: Taking false branch
254.   		{
255.   		DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);
256.   		if (kinv != NULL) BN_clear_free(kinv);
             ^
257.   		if (r != NULL) BN_clear_free(r);
258.   		}

crypto/dsa/dsa_ossl.c:257:7: Taking false branch
255.   		DSAerr(DSA_F_DSA_SIGN_SETUP,ERR_R_BN_LIB);
256.   		if (kinv != NULL) BN_clear_free(kinv);
257.   		if (r != NULL) BN_clear_free(r);
             ^
258.   		}
259.   	if (ctx_in == NULL) BN_CTX_free(ctx);

crypto/dsa/dsa_ossl.c:259:6: Taking true branch
257.   		if (r != NULL) BN_clear_free(r);
258.   		}
259.   	if (ctx_in == NULL) BN_CTX_free(ctx);
            ^
260.   	if (kinv != NULL) BN_clear_free(kinv);
261.   	BN_clear_free(&k);

crypto/dsa/dsa_ossl.c:259:22: 
257.   		if (r != NULL) BN_clear_free(r);
258.   		}
259. > 	if (ctx_in == NULL) BN_CTX_free(ctx);
260.   	if (kinv != NULL) BN_clear_free(kinv);
261.   	BN_clear_free(&k);
