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


apps/apps.c:941:1: start of procedure load_netscape_key()
939.   
940.   #if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
941. > static EVP_PKEY *
942.   load_netscape_key(BIO *err, BIO *key, const char *file,
943.   		const char *key_descrip, int format)

apps/apps.c:951:2: 
949.   	int size, i;
950.   
951. > 	buf=BUF_MEM_new();
952.   	pkey = EVP_PKEY_new();
953.   	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: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/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:952:2: 
950.   
951.   	buf=BUF_MEM_new();
952. > 	pkey = EVP_PKEY_new();
953.   	size = 0;
954.   	if (buf == NULL || pkey == NULL)

crypto/evp/p_lib.c:298:1: start of procedure EVP_PKEY_new()
  296.   	}
  297.   
  298. > EVP_PKEY *EVP_PKEY_new(void)
  299.   	{
  300.   	EVP_PKEY *ret;

crypto/evp/p_lib.c:302:2: 
  300.   	EVP_PKEY *ret;
  301.   
  302. > 	ret=(EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY));
  303.   	if (ret == NULL)
  304.   		{

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:303:6: Taking true branch
  301.   
  302.   	ret=(EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY));
  303.   	if (ret == NULL)
              ^
  304.   		{
  305.   		EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);

crypto/evp/p_lib.c:305:3: 
  303.   	if (ret == NULL)
  304.   		{
  305. > 		EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);
  306.   		return(NULL);
  307.   		}

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/evp/p_lib.c:306:3: 
  304.   		{
  305.   		EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);
  306. > 		return(NULL);
  307.   		}
  308.   	ret->type=EVP_PKEY_NONE;

crypto/evp/p_lib.c:314:2: return from a call to EVP_PKEY_new
  312.   	ret->save_parameters=1;
  313.   	return(ret);
  314.   	}
          ^
  315.   
  316.   int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key)

apps/apps.c:953:2: 
951.   	buf=BUF_MEM_new();
952.   	pkey = EVP_PKEY_new();
953. > 	size = 0;
954.   	if (buf == NULL || pkey == NULL)
955.   		goto error;

apps/apps.c:954:6: Taking true branch
952.   	pkey = EVP_PKEY_new();
953.   	size = 0;
954.   	if (buf == NULL || pkey == NULL)
            ^
955.   		goto error;
956.   	for (;;)

apps/apps.c:979:1: 
977.   	EVP_PKEY_set1_RSA(pkey, rsa);
978.   	return pkey;
979. > error:
980.   	BUF_MEM_free(buf);
981.   	EVP_PKEY_free(pkey);

apps/apps.c:980:2: 
978.   	return pkey;
979.   error:
980. > 	BUF_MEM_free(buf);
981.   	EVP_PKEY_free(pkey);
982.   	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:981:2: 
979.   error:
980.   	BUF_MEM_free(buf);
981. > 	EVP_PKEY_free(pkey);
982.   	return NULL;
983.   	}
