crypto/engine/hw_sureware.c:985: error: NULL_DEREFERENCE
  pointer `psign` last assigned on line 957 could be null and is dereferenced at line 985, column 2.
Showing all 50 steps of the trace


crypto/engine/hw_sureware.c:953:1: start of procedure surewarehk_dsa_do_sign()
951.   #ifndef OPENSSL_NO_DSA
952.   /* DSA sign and verify */
953. > static	DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)
954.   {
955.   	int ret=0;

crypto/engine/hw_sureware.c:955:2: 
953.   static	DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)
954.   {
955. > 	int ret=0;
956.   	char *hptr=NULL;
957.   	DSA_SIG *psign=NULL;

crypto/engine/hw_sureware.c:956:2: 
954.   {
955.   	int ret=0;
956. > 	char *hptr=NULL;
957.   	DSA_SIG *psign=NULL;
958.   	char msg[64]="ENGINE_dsa_do_sign";

crypto/engine/hw_sureware.c:957:2: 
955.   	int ret=0;
956.   	char *hptr=NULL;
957. > 	DSA_SIG *psign=NULL;
958.   	char msg[64]="ENGINE_dsa_do_sign";
959.   	if (!p_surewarehk_Dsa_Sign)

crypto/engine/hw_sureware.c:958:2: 
956.   	char *hptr=NULL;
957.   	DSA_SIG *psign=NULL;
958. > 	char msg[64]="ENGINE_dsa_do_sign";
959.   	if (!p_surewarehk_Dsa_Sign)
960.   	{

crypto/engine/hw_sureware.c:959:7: Taking false branch
957.   	DSA_SIG *psign=NULL;
958.   	char msg[64]="ENGINE_dsa_do_sign";
959.   	if (!p_surewarehk_Dsa_Sign)
             ^
960.   	{
961.   		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ENGINE_R_NOT_INITIALISED);

crypto/engine/hw_sureware.c:964:13: 
962.   	}
963.   	/* extract ref to private key */
964. > 	else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
965.   	{
966.   		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);

crypto/dsa/dsa_lib.c:254:1: start of procedure DSA_get_ex_data()
  252.   	}
  253.   
  254. > void *DSA_get_ex_data(DSA *d, int idx)
  255.   	{
  256.   	return(CRYPTO_get_ex_data(&d->ex_data,idx));

crypto/dsa/dsa_lib.c:256:2: 
  254.   void *DSA_get_ex_data(DSA *d, int idx)
  255.   	{
  256. > 	return(CRYPTO_get_ex_data(&d->ex_data,idx));
  257.   	}
  258.   

crypto/ex_data.c:626:1: start of procedure CRYPTO_get_ex_data()
    624.   /* For a given CRYPTO_EX_DATA_ variable, get the value corresponding to a
    625.    * particular index in the class used by this variable */
    626. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    627.   	{
    628.   	if (ad->sk == NULL)

crypto/ex_data.c:628:6: Taking false branch
    626.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    627.   	{
    628.   	if (ad->sk == NULL)
                ^
    629.   		return(0);
    630.   	else if (idx >= sk_num(ad->sk))

crypto/ex_data.c:630:11: 
    628.   	if (ad->sk == NULL)
    629.   		return(0);
    630. > 	else if (idx >= sk_num(ad->sk))
    631.   		return(0);
    632.   	else

crypto/stack/stack.c:301:1: start of procedure sk_num()
      299.   	}
      300.   
      301. > int sk_num(const STACK *st)
      302.   {
      303.   	if(st == NULL) return -1;

crypto/stack/stack.c:303:5: Taking false branch
      301.   int sk_num(const STACK *st)
      302.   {
      303.   	if(st == NULL) return -1;
                 ^
      304.   	return st->num;
      305.   }

crypto/stack/stack.c:304:2: 
      302.   {
      303.   	if(st == NULL) return -1;
      304. > 	return st->num;
      305.   }
      306.   

crypto/stack/stack.c:305:1: return from a call to sk_num
      303.   	if(st == NULL) return -1;
      304.   	return st->num;
      305. > }
      306.   
      307.   char *sk_value(const STACK *st, int i)

crypto/ex_data.c:630:11: Taking false branch
    628.   	if (ad->sk == NULL)
    629.   		return(0);
    630.   	else if (idx >= sk_num(ad->sk))
                     ^
    631.   		return(0);
    632.   	else

crypto/ex_data.c:633:3: 
    631.   		return(0);
    632.   	else
    633. > 		return(sk_value(ad->sk,idx));
    634.   	}
    635.   

crypto/stack/stack.c:307:1: start of procedure sk_value()
      305.   }
      306.   
      307. > char *sk_value(const STACK *st, int i)
      308.   {
      309.   	if(st == NULL) return NULL;

crypto/stack/stack.c:309:5: Taking false branch
      307.   char *sk_value(const STACK *st, int i)
      308.   {
      309.   	if(st == NULL) return NULL;
                 ^
      310.   	return st->data[i];
      311.   }

crypto/stack/stack.c:310:2: 
      308.   {
      309.   	if(st == NULL) return NULL;
      310. > 	return st->data[i];
      311.   }
      312.   

crypto/stack/stack.c:311:1: return from a call to sk_value
      309.   	if(st == NULL) return NULL;
      310.   	return st->data[i];
      311. > }
      312.   
      313.   char *sk_set(STACK *st, int i, char *value)

crypto/ex_data.c:634:2: return from a call to CRYPTO_get_ex_data
    632.   	else
    633.   		return(sk_value(ad->sk,idx));
    634.   	}
            ^
    635.   
    636.   IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS)

crypto/dsa/dsa_lib.c:257:2: return from a call to DSA_get_ex_data
  255.   	{
  256.   	return(CRYPTO_get_ex_data(&d->ex_data,idx));
  257.   	}
          ^
  258.   
  259.   #ifndef OPENSSL_NO_DH

crypto/engine/hw_sureware.c:964:13: Taking true branch
962.   	}
963.   	/* extract ref to private key */
964.   	else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
                   ^
965.   	{
966.   		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);

crypto/engine/hw_sureware.c:966:3: 
964.   	else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
965.   	{
966. > 		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);
967.   	}
968.   	else

crypto/engine/hw_sureware_err.c:145:1: start of procedure ERR_SUREWARE_error()
  143.   	}
  144.   
  145. > static void ERR_SUREWARE_error(int function, int reason, char *file, int line)
  146.   	{
  147.   	if (SUREWARE_lib_error_code == 0)

crypto/engine/hw_sureware_err.c:147:6: Taking true branch
  145.   static void ERR_SUREWARE_error(int function, int reason, char *file, int line)
  146.   	{
  147.   	if (SUREWARE_lib_error_code == 0)
              ^
  148.   		SUREWARE_lib_error_code=ERR_get_next_error_library();
  149.   	ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);

crypto/engine/hw_sureware_err.c:148:3: 
  146.   	{
  147.   	if (SUREWARE_lib_error_code == 0)
  148. > 		SUREWARE_lib_error_code=ERR_get_next_error_library();
  149.   	ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);
  150.   	}

crypto/err/err.c:971:1: start of procedure ERR_get_next_error_library()
    969.   	}
    970.   
    971. > int ERR_get_next_error_library(void)
    972.   	{
    973.   	err_fns_check();

crypto/err/err.c:973:2: 
    971.   int ERR_get_next_error_library(void)
    972.   	{
    973. > 	err_fns_check();
    974.   	return ERRFN(get_next_lib)();
    975.   	}

crypto/err/err.c:276:1: start of procedure err_fns_check()
      274.   /* Internal function that checks whether "err_fns" is set and if not, sets it to
      275.    * the defaults. */
      276. > static void err_fns_check(void)
      277.   	{
      278.   	if (err_fns) return;

crypto/err/err.c:278:6: Taking true branch
      276.   static void err_fns_check(void)
      277.   	{
      278.   	if (err_fns) return;
                  ^
      279.   	
      280.   	CRYPTO_w_lock(CRYPTO_LOCK_ERR);

crypto/err/err.c:278:15: 
      276.   static void err_fns_check(void)
      277.   	{
      278. > 	if (err_fns) return;
      279.   	
      280.   	CRYPTO_w_lock(CRYPTO_LOCK_ERR);

crypto/err/err.c:284:2: return from a call to err_fns_check
      282.   		err_fns = &err_defaults;
      283.   	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
      284.   	}
              ^
      285.   
      286.   /* API functions to get or set the underlying ERR functions. */

crypto/err/err.c:974:2: Skipping __function_pointer__(): unresolved function pointer
    972.   	{
    973.   	err_fns_check();
    974.   	return ERRFN(get_next_lib)();
            ^
    975.   	}
    976.   

crypto/err/err.c:975:2: return from a call to ERR_get_next_error_library
    973.   	err_fns_check();
    974.   	return ERRFN(get_next_lib)();
    975.   	}
            ^
    976.   
    977.   void ERR_set_error_data(char *data, int flags)

crypto/engine/hw_sureware_err.c:149:2: 
  147.   	if (SUREWARE_lib_error_code == 0)
  148.   		SUREWARE_lib_error_code=ERR_get_next_error_library();
  149. > 	ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);
  150.   	}

crypto/err/err.c:615:1: start of procedure ERR_put_error()
    613.   /********************************************************/
    614.   
    615. > void ERR_put_error(int lib, int func, int reason, const char *file,
    616.   	     int line)
    617.   	{

crypto/err/err.c:639:2: Skipping ERR_get_state(): empty list of specs
    637.   	}
    638.   #endif
    639.   	es=ERR_get_state();
            ^
    640.   
    641.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:641:2: 
    639.   	es=ERR_get_state();
    640.   
    641. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    642.   	if (es->top == es->bottom)
    643.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:642:6: Taking false branch
    640.   
    641.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    642.   	if (es->top == es->bottom)
                ^
    643.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    644.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);

crypto/err/err.c:644:2: 
    642.   	if (es->top == es->bottom)
    643.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    644. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    645.   	es->err_file[es->top]=file;
    646.   	es->err_line[es->top]=line;

crypto/err/err.c:645:2: 
    643.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    644.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    645. > 	es->err_file[es->top]=file;
    646.   	es->err_line[es->top]=line;
    647.   	err_clear_data(es,es->top);

crypto/err/err.c:646:2: 
    644.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    645.   	es->err_file[es->top]=file;
    646. > 	es->err_line[es->top]=line;
    647.   	err_clear_data(es,es->top);
    648.   	}

crypto/err/err.c:647:2: Taking true branch
    645.   	es->err_file[es->top]=file;
    646.   	es->err_line[es->top]=line;
    647.   	err_clear_data(es,es->top);
            ^
    648.   	}
    649.   

crypto/err/err.c:647:2: Taking false branch
    645.   	es->err_file[es->top]=file;
    646.   	es->err_line[es->top]=line;
    647.   	err_clear_data(es,es->top);
            ^
    648.   	}
    649.   

crypto/err/err.c:648:2: return from a call to ERR_put_error
    646.   	es->err_line[es->top]=line;
    647.   	err_clear_data(es,es->top);
    648.   	}
            ^
    649.   
    650.   void ERR_clear_error(void)

crypto/engine/hw_sureware_err.c:150:2: return from a call to ERR_SUREWARE_error
  148.   		SUREWARE_lib_error_code=ERR_get_next_error_library();
  149.   	ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);
  150.   	}
          ^

crypto/engine/hw_sureware.c:985:2: 
983.   		surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ret);
984.   	}
985. > 	psign->r->top=20/sizeof(BN_ULONG);
986.   	bn_fix_top(psign->r);
987.   	psign->s->top=20/sizeof(BN_ULONG);
