apps/apps.c:1034: error: NULL_DEREFERENCE
  pointer `pkey` last assigned on line 1005 could be null and is dereferenced by call to `EVP_PKEY_free()` at line 1034, column 2.
Showing all 74 steps of the trace


apps/apps.c:994:1: start of procedure load_netscape_key()
992.   
993.   #if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
994. > static EVP_PKEY *
995.   load_netscape_key(BIO *err, BIO *key, const char *file,
996.   		const char *key_descrip, int format)

apps/apps.c:1004:2: 
1002.   	int size, i;
1003.   
1004. > 	buf=BUF_MEM_new();
1005.   	pkey = EVP_PKEY_new();
1006.   	size = 0;

crypto/buffer/buffer.c:63:1: start of procedure BUF_MEM_new()
  61.   #include <openssl/buffer.h>
  62.   
  63. > BUF_MEM *BUF_MEM_new(void)
  64.   	{
  65.   	BUF_MEM *ret;

crypto/buffer/buffer.c:67:2: 
  65.   	BUF_MEM *ret;
  66.   
  67. > 	ret=OPENSSL_malloc(sizeof(BUF_MEM));
  68.   	if (ret == NULL)
  69.   		{

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/buffer/buffer.c:68:6: Taking true branch
  66.   
  67.   	ret=OPENSSL_malloc(sizeof(BUF_MEM));
  68.   	if (ret == NULL)
             ^
  69.   		{
  70.   		BUFerr(BUF_F_BUF_MEM_NEW,ERR_R_MALLOC_FAILURE);

crypto/buffer/buffer.c:70:3: 
  68.   	if (ret == NULL)
  69.   		{
  70. > 		BUFerr(BUF_F_BUF_MEM_NEW,ERR_R_MALLOC_FAILURE);
  71.   		return(NULL);
  72.   		}

crypto/err/err.c:630:1: start of procedure ERR_put_error()
    628.   /********************************************************/
    629.   
    630. > void ERR_put_error(int lib, int func, int reason, const char *file,
    631.   	     int line)
    632.   	{

crypto/err/err.c:654:2: Skipping ERR_get_state(): empty list of specs
    652.   	}
    653.   #endif
    654.   	es=ERR_get_state();
            ^
    655.   
    656.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:656:2: 
    654.   	es=ERR_get_state();
    655.   
    656. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    657.   	if (es->top == es->bottom)
    658.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:657:6: Taking false branch
    655.   
    656.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    657.   	if (es->top == es->bottom)
                ^
    658.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    659.   	es->err_flags[es->top]=0;

crypto/err/err.c:659:2: 
    657.   	if (es->top == es->bottom)
    658.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    659. > 	es->err_flags[es->top]=0;
    660.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    661.   	es->err_file[es->top]=file;

crypto/err/err.c:660:2: 
    658.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    659.   	es->err_flags[es->top]=0;
    660. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    661.   	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;

crypto/err/err.c:661:2: 
    659.   	es->err_flags[es->top]=0;
    660.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    661. > 	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);

crypto/err/err.c:662:2: 
    660.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    661.   	es->err_file[es->top]=file;
    662. > 	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
    664.   	}

crypto/err/err.c:663:2: Taking true branch
    661.   	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
            ^
    664.   	}
    665.   

crypto/err/err.c:663:2: Taking false branch
    661.   	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
            ^
    664.   	}
    665.   

crypto/err/err.c:663:2: Loop condition is false. Leaving loop
    661.   	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
            ^
    664.   	}
    665.   

crypto/err/err.c:664:2: return from a call to ERR_put_error
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
    664.   	}
            ^
    665.   
    666.   void ERR_clear_error(void)

crypto/buffer/buffer.c:71:3: 
  69.   		{
  70.   		BUFerr(BUF_F_BUF_MEM_NEW,ERR_R_MALLOC_FAILURE);
  71. > 		return(NULL);
  72.   		}
  73.   	ret->length=0;

crypto/buffer/buffer.c:77:2: return from a call to BUF_MEM_new
  75.   	ret->data=NULL;
  76.   	return(ret);
  77.   	}
         ^
  78.   
  79.   void BUF_MEM_free(BUF_MEM *a)

apps/apps.c:1005:2: 
1003.   
1004.   	buf=BUF_MEM_new();
1005. > 	pkey = EVP_PKEY_new();
1006.   	size = 0;
1007.   	if (buf == NULL || pkey == NULL)

crypto/evp/p_lib.c:289:1: start of procedure EVP_PKEY_new()
  287.   	}
  288.   
  289. > EVP_PKEY *EVP_PKEY_new(void)
  290.   	{
  291.   	EVP_PKEY *ret;

crypto/evp/p_lib.c:293:2: 
  291.   	EVP_PKEY *ret;
  292.   
  293. > 	ret=(EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY));
  294.   	if (ret == NULL)
  295.   		{

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/evp/p_lib.c:294:6: Taking true branch
  292.   
  293.   	ret=(EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY));
  294.   	if (ret == NULL)
              ^
  295.   		{
  296.   		EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);

crypto/evp/p_lib.c:296:3: 
  294.   	if (ret == NULL)
  295.   		{
  296. > 		EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);
  297.   		return(NULL);
  298.   		}

crypto/err/err.c:630:1: start of procedure ERR_put_error()
    628.   /********************************************************/
    629.   
    630. > void ERR_put_error(int lib, int func, int reason, const char *file,
    631.   	     int line)
    632.   	{

crypto/err/err.c:654:2: Skipping ERR_get_state(): empty list of specs
    652.   	}
    653.   #endif
    654.   	es=ERR_get_state();
            ^
    655.   
    656.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:656:2: 
    654.   	es=ERR_get_state();
    655.   
    656. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    657.   	if (es->top == es->bottom)
    658.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:657:6: Taking false branch
    655.   
    656.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    657.   	if (es->top == es->bottom)
                ^
    658.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    659.   	es->err_flags[es->top]=0;

crypto/err/err.c:659:2: 
    657.   	if (es->top == es->bottom)
    658.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    659. > 	es->err_flags[es->top]=0;
    660.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    661.   	es->err_file[es->top]=file;

crypto/err/err.c:660:2: 
    658.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    659.   	es->err_flags[es->top]=0;
    660. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    661.   	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;

crypto/err/err.c:661:2: 
    659.   	es->err_flags[es->top]=0;
    660.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    661. > 	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);

crypto/err/err.c:662:2: 
    660.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    661.   	es->err_file[es->top]=file;
    662. > 	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
    664.   	}

crypto/err/err.c:663:2: Taking true branch
    661.   	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
            ^
    664.   	}
    665.   

crypto/err/err.c:663:2: Taking false branch
    661.   	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
            ^
    664.   	}
    665.   

crypto/err/err.c:663:2: Loop condition is false. Leaving loop
    661.   	es->err_file[es->top]=file;
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
            ^
    664.   	}
    665.   

crypto/err/err.c:664:2: return from a call to ERR_put_error
    662.   	es->err_line[es->top]=line;
    663.   	err_clear_data(es,es->top);
    664.   	}
            ^
    665.   
    666.   void ERR_clear_error(void)

crypto/evp/p_lib.c:297:3: 
  295.   		{
  296.   		EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);
  297. > 		return(NULL);
  298.   		}
  299.   	ret->type=EVP_PKEY_NONE;

crypto/evp/p_lib.c:305:2: return from a call to EVP_PKEY_new
  303.   	ret->save_parameters=1;
  304.   	return(ret);
  305.   	}
          ^
  306.   
  307.   int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key)

apps/apps.c:1006:2: 
1004.   	buf=BUF_MEM_new();
1005.   	pkey = EVP_PKEY_new();
1006. > 	size = 0;
1007.   	if (buf == NULL || pkey == NULL)
1008.   		goto error;

apps/apps.c:1007:6: Taking true branch
1005.   	pkey = EVP_PKEY_new();
1006.   	size = 0;
1007.   	if (buf == NULL || pkey == NULL)
             ^
1008.   		goto error;
1009.   	for (;;)

apps/apps.c:1032:1: 
1030.   	EVP_PKEY_set1_RSA(pkey, rsa);
1031.   	return pkey;
1032. > error:
1033.   	BUF_MEM_free(buf);
1034.   	EVP_PKEY_free(pkey);

apps/apps.c:1033:2: 
1031.   	return pkey;
1032.   error:
1033. > 	BUF_MEM_free(buf);
1034.   	EVP_PKEY_free(pkey);
1035.   	return NULL;

crypto/buffer/buffer.c:79:1: start of procedure BUF_MEM_free()
  77.   	}
  78.   
  79. > void BUF_MEM_free(BUF_MEM *a)
  80.   	{
  81.   	if(a == NULL)

crypto/buffer/buffer.c:81:5: Taking true branch
  79.   void BUF_MEM_free(BUF_MEM *a)
  80.   	{
  81.   	if(a == NULL)
            ^
  82.   	    return;
  83.   

crypto/buffer/buffer.c:82:6: 
  80.   	{
  81.   	if(a == NULL)
  82. > 	    return;
  83.   
  84.   	if (a->data != NULL)

crypto/buffer/buffer.c:90:2: return from a call to BUF_MEM_free
  88.   		}
  89.   	OPENSSL_free(a);
  90.   	}
         ^
  91.   
  92.   int BUF_MEM_grow(BUF_MEM *str, int len)

apps/apps.c:1034:2: 
1032.   error:
1033.   	BUF_MEM_free(buf);
1034. > 	EVP_PKEY_free(pkey);
1035.   	return NULL;
1036.   	}
