engines/e_ubsec.c:947: error: NULL_DEREFERENCE
  pointer `pub_key` last assigned on line 945 could be null and is dereferenced at line 947, column 17.
Showing all 48 steps of the trace


engines/e_ubsec.c:912:1: start of procedure ubsec_dh_generate_key()
910.           }
911.   
912. > static int ubsec_dh_generate_key (DH *dh)
913.           {
914.           int      ret               = 0,

engines/e_ubsec.c:914:9: 
912.   static int ubsec_dh_generate_key (DH *dh)
913.           {
914. >         int      ret               = 0,
915.                    random_bits       = 0,
916.                    pub_key_len       = 0,

engines/e_ubsec.c:919:9: 
917.                    priv_key_len      = 0,
918.                    fd;
919. >         BIGNUM   *pub_key          = NULL;
920.           BIGNUM   *priv_key         = NULL;
921.   

engines/e_ubsec.c:920:9: 
918.                    fd;
919.           BIGNUM   *pub_key          = NULL;
920. >         BIGNUM   *priv_key         = NULL;
921.   
922.           /* 

engines/e_ubsec.c:927:13: Taking false branch
925.            */
926.   
927.           if (dh->priv_key == NULL)
                   ^
928.                   {
929.                   priv_key = BN_new();

engines/e_ubsec.c:940:17: 
938.           else
939.                   {
940. >                 priv_key = dh->priv_key;
941.                   }
942.   

engines/e_ubsec.c:943:13: Taking true branch
941.                   }
942.   
943.           if (dh->pub_key == NULL)
                   ^
944.                   {
945.                   pub_key = BN_new();

engines/e_ubsec.c:945:17: 
943.           if (dh->pub_key == NULL)
944.                   {
945. >                 pub_key = BN_new();
946.                   pub_key_len = BN_num_bits(dh->p);
947.                   bn_wexpand(pub_key, dh->p->top);

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

crypto/bn/bn_lib.c:296:6: 
  294.   	BIGNUM *ret;
  295.   
  296. > 	if ((ret=(BIGNUM *)OPENSSL_malloc(sizeof(BIGNUM))) == NULL)
  297.   		{
  298.   		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);

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_lib.c:296:6: Taking true branch
  294.   	BIGNUM *ret;
  295.   
  296.   	if ((ret=(BIGNUM *)OPENSSL_malloc(sizeof(BIGNUM))) == NULL)
              ^
  297.   		{
  298.   		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:298:3: 
  296.   	if ((ret=(BIGNUM *)OPENSSL_malloc(sizeof(BIGNUM))) == NULL)
  297.   		{
  298. > 		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);
  299.   		return(NULL);
  300.   		}

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_lib.c:299:3: 
  297.   		{
  298.   		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);
  299. > 		return(NULL);
  300.   		}
  301.   	ret->flags=BN_FLG_MALLOCED;

crypto/bn/bn_lib.c:308:2: return from a call to BN_new
  306.   	bn_check_top(ret);
  307.   	return(ret);
  308.   	}
          ^
  309.   
  310.   /* This is used both by bn_expand2() and bn_dup_expand() */

engines/e_ubsec.c:946:17: 
944.                   {
945.                   pub_key = BN_new();
946. >                 pub_key_len = BN_num_bits(dh->p);
947.                   bn_wexpand(pub_key, dh->p->top);
948.                   if(pub_key == NULL) goto err;

crypto/bn/bn_lib.c:245:1: start of procedure BN_num_bits()
  243.   	}
  244.   
  245. > int BN_num_bits(const BIGNUM *a)
  246.   	{
  247.   	BN_ULONG l;

crypto/bn/bn_lib.c:252:6: Taking false branch
  250.   	bn_check_top(a);
  251.   
  252.   	if (a->top == 0) return(0);
              ^
  253.   	l=a->d[a->top-1];
  254.   	assert(l != 0);

crypto/bn/bn_lib.c:253:2: 
  251.   
  252.   	if (a->top == 0) return(0);
  253. > 	l=a->d[a->top-1];
  254.   	assert(l != 0);
  255.   	i=(a->top-1)*BN_BITS2;

crypto/bn/bn_lib.c:254:2: 
  252.   	if (a->top == 0) return(0);
  253.   	l=a->d[a->top-1];
  254. > 	assert(l != 0);
  255.   	i=(a->top-1)*BN_BITS2;
  256.   	return(i+BN_num_bits_word(l));

crypto/bn/bn_lib.c:255:2: 
  253.   	l=a->d[a->top-1];
  254.   	assert(l != 0);
  255. > 	i=(a->top-1)*BN_BITS2;
  256.   	return(i+BN_num_bits_word(l));
  257.   	}

crypto/bn/bn_lib.c:256:2: Skipping BN_num_bits_word(): empty list of specs
  254.   	assert(l != 0);
  255.   	i=(a->top-1)*BN_BITS2;
  256.   	return(i+BN_num_bits_word(l));
          ^
  257.   	}
  258.   

crypto/bn/bn_lib.c:257:2: return from a call to BN_num_bits
  255.   	i=(a->top-1)*BN_BITS2;
  256.   	return(i+BN_num_bits_word(l));
  257.   	}
          ^
  258.   
  259.   void BN_clear_free(BIGNUM *a)

engines/e_ubsec.c:947:17: 
945.                   pub_key = BN_new();
946.                   pub_key_len = BN_num_bits(dh->p);
947. >                 bn_wexpand(pub_key, dh->p->top);
948.                   if(pub_key == NULL) goto err;
949.                   }
