engines/e_ncipher.c:873: error: NULL_DEREFERENCE
  pointer `res->pkey.rsa` last assigned on line 872 could be null and is dereferenced at line 873, column 4.
Showing all 52 steps of the trace


engines/e_ncipher.c:852:1: start of procedure hwcrhk_load_pubkey()
850.   	}
851.   
852. > static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
853.   	UI_METHOD *ui_method, void *callback_data)
854.   	{

engines/e_ncipher.c:855:2: 
853.   	UI_METHOD *ui_method, void *callback_data)
854.   	{
855. > 	EVP_PKEY *res = NULL;
856.   
857.   #ifndef OPENSSL_NO_RSA

engines/e_ncipher.c:858:9: Skipping hwcrhk_load_privkey(): empty list of specs
856.   
857.   #ifndef OPENSSL_NO_RSA
858.           res = hwcrhk_load_privkey(eng, key_id,
               ^
859.                   ui_method, callback_data);
860.   #endif

engines/e_ncipher.c:862:6: Taking true branch
860.   #endif
861.   
862.   	if (res)
            ^
863.   		switch(res->type)
864.   			{

engines/e_ncipher.c:863:3: 
861.   
862.   	if (res)
863. > 		switch(res->type)
864.   			{
865.   #ifndef OPENSSL_NO_RSA

engines/e_ncipher.c:866:3: Switch condition is true. Entering switch case
864.   			{
865.   #ifndef OPENSSL_NO_RSA
866.   		case EVP_PKEY_RSA:
         ^
867.   			{
868.   			RSA *rsa = NULL;

engines/e_ncipher.c:868:4: 
866.   		case EVP_PKEY_RSA:
867.   			{
868. > 			RSA *rsa = NULL;
869.   
870.   			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);

engines/e_ncipher.c:870:4: 
868.   			RSA *rsa = NULL;
869.   
870. > 			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
871.   			rsa = res->pkey.rsa;
872.   			res->pkey.rsa = RSA_new();

crypto/cryptlib.c:448:1: start of procedure CRYPTO_lock()
  446.   	}
  447.   
  448. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  449.   	{
  450.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:473:6: Taking false branch
  471.   		}
  472.   #endif
  473.   	if (type < 0)
              ^
  474.   		{
  475.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:488:7: Taking true branch
  486.   		}
  487.   	else
  488.   		if (locking_callback != NULL)
               ^
  489.   			locking_callback(mode,type,file,line);
  490.   	}

crypto/cryptlib.c:489:4: Skipping __function_pointer__(): unresolved function pointer
  487.   	else
  488.   		if (locking_callback != NULL)
  489.   			locking_callback(mode,type,file,line);
            ^
  490.   	}
  491.   

crypto/cryptlib.c:473:2: 
  471.   		}
  472.   #endif
  473. > 	if (type < 0)
  474.   		{
  475.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:490:2: return from a call to CRYPTO_lock
  488.   		if (locking_callback != NULL)
  489.   			locking_callback(mode,type,file,line);
  490.   	}
          ^
  491.   
  492.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

engines/e_ncipher.c:871:4: 
869.   
870.   			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
871. > 			rsa = res->pkey.rsa;
872.   			res->pkey.rsa = RSA_new();
873.   			res->pkey.rsa->n = rsa->n;

engines/e_ncipher.c:872:4: 
870.   			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
871.   			rsa = res->pkey.rsa;
872. > 			res->pkey.rsa = RSA_new();
873.   			res->pkey.rsa->n = rsa->n;
874.   			res->pkey.rsa->e = rsa->e;

crypto/rsa/rsa_lib.c:74:1: start of procedure RSA_new()
  72.   static const RSA_METHOD *default_RSA_meth=NULL;
  73.   
  74. > RSA *RSA_new(void)
  75.   	{
  76.   	RSA *r=RSA_new_method(NULL);

crypto/rsa/rsa_lib.c:76:2: 
  74.   RSA *RSA_new(void)
  75.   	{
  76. > 	RSA *r=RSA_new_method(NULL);
  77.   
  78.   	return r;

crypto/rsa/rsa_lib.c:128:1: start of procedure RSA_new_method()
    126.   	}
    127.   
    128. > RSA *RSA_new_method(ENGINE *engine)
    129.   	{
    130.   	RSA *ret;

crypto/rsa/rsa_lib.c:132:2: 
    130.   	RSA *ret;
    131.   
    132. > 	ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
    133.   	if (ret == NULL)
    134.   		{

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/rsa/rsa_lib.c:133:6: Taking true branch
    131.   
    132.   	ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
    133.   	if (ret == NULL)
                ^
    134.   		{
    135.   		RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);

crypto/rsa/rsa_lib.c:135:3: 
    133.   	if (ret == NULL)
    134.   		{
    135. > 		RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
    136.   		return NULL;
    137.   		}

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/rsa/rsa_lib.c:136:3: 
    134.   		{
    135.   		RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
    136. > 		return NULL;
    137.   		}
    138.   

crypto/rsa/rsa_lib.c:196:2: return from a call to RSA_new_method
    194.   		}
    195.   	return(ret);
    196.   	}
            ^
    197.   
    198.   void RSA_free(RSA *r)

crypto/rsa/rsa_lib.c:78:2: 
  76.   	RSA *r=RSA_new_method(NULL);
  77.   
  78. > 	return r;
  79.   	}
  80.   

crypto/rsa/rsa_lib.c:79:2: return from a call to RSA_new
  77.   
  78.   	return r;
  79.   	}
         ^
  80.   
  81.   void RSA_set_default_method(const RSA_METHOD *meth)

engines/e_ncipher.c:873:4: 
871.   			rsa = res->pkey.rsa;
872.   			res->pkey.rsa = RSA_new();
873. > 			res->pkey.rsa->n = rsa->n;
874.   			res->pkey.rsa->e = rsa->e;
875.   			rsa->n = NULL;
