ssl/s3_clnt.c:2307: error: NULL_DEREFERENCE
  pointer `pkey` last assigned on line 2305 could be null and is dereferenced by call to `EVP_PKEY_free()` at line 2307, column 2.
Showing all 79 steps of the trace


ssl/s3_clnt.c:2253:1: start of procedure ssl3_check_cert_and_algorithm()
2251.   #define has_bits(i,m)	(((i)&(m)) == (m))
2252.   
2253. > static int ssl3_check_cert_and_algorithm(SSL *s)
2254.   	{
2255.   	int i,idx;

ssl/s3_clnt.c:2257:2: 
2255.   	int i,idx;
2256.   	long algs;
2257. > 	EVP_PKEY *pkey=NULL;
2258.   	SESS_CERT *sc;
2259.   #ifndef OPENSSL_NO_RSA

ssl/s3_clnt.c:2266:2: 
2264.   #endif
2265.   
2266. > 	sc=s->session->sess_cert;
2267.   
2268.   	if (sc == NULL)

ssl/s3_clnt.c:2268:6: Taking false branch
2266.   	sc=s->session->sess_cert;
2267.   
2268.   	if (sc == NULL)
             ^
2269.   		{
2270.   		SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,ERR_R_INTERNAL_ERROR);

ssl/s3_clnt.c:2274:2: 
2272.   		}
2273.   
2274. > 	algs=s->s3->tmp.new_cipher->algorithms;
2275.   
2276.   	/* we don't have a certificate */

ssl/s3_clnt.c:2277:6: Taking false branch
2275.   
2276.   	/* we don't have a certificate */
2277.   	if (algs & (SSL_aDH|SSL_aNULL|SSL_aKRB5))
             ^
2278.   		return(1);
2279.   

ssl/s3_clnt.c:2281:2: 
2279.   
2280.   #ifndef OPENSSL_NO_RSA
2281. > 	rsa=s->session->sess_cert->peer_rsa_tmp;
2282.   #endif
2283.   #ifndef OPENSSL_NO_DH

ssl/s3_clnt.c:2284:2: 
2282.   #endif
2283.   #ifndef OPENSSL_NO_DH
2284. > 	dh=s->session->sess_cert->peer_dh_tmp;
2285.   #endif
2286.   

ssl/s3_clnt.c:2289:2: 
2287.   	/* This is the passed certificate */
2288.   
2289. > 	idx=sc->peer_cert_type;
2290.   #ifndef OPENSSL_NO_ECDH
2291.   	if (idx == SSL_PKEY_ECC)

ssl/s3_clnt.c:2291:6: Taking false branch
2289.   	idx=sc->peer_cert_type;
2290.   #ifndef OPENSSL_NO_ECDH
2291.   	if (idx == SSL_PKEY_ECC)
             ^
2292.   		{
2293.   		if (check_srvr_ecc_cert_and_alg(sc->peer_pkeys[idx].x509,

ssl/s3_clnt.c:2305:2: 
2303.   		}
2304.   #endif
2305. > 	pkey=X509_get_pubkey(sc->peer_pkeys[idx].x509);
2306.   	i=X509_certificate_type(sc->peer_pkeys[idx].x509,pkey);
2307.   	EVP_PKEY_free(pkey);

crypto/x509/x509_cmp.c:358:1: start of procedure X509_get_pubkey()
  356.   	}
  357.   
  358. > EVP_PKEY *X509_get_pubkey(X509 *x)
  359.   	{
  360.   	if ((x == NULL) || (x->cert_info == NULL))

crypto/x509/x509_cmp.c:360:7: Taking false branch
  358.   EVP_PKEY *X509_get_pubkey(X509 *x)
  359.   	{
  360.   	if ((x == NULL) || (x->cert_info == NULL))
               ^
  361.   		return(NULL);
  362.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:360:22: Taking false branch
  358.   EVP_PKEY *X509_get_pubkey(X509 *x)
  359.   	{
  360.   	if ((x == NULL) || (x->cert_info == NULL))
                              ^
  361.   		return(NULL);
  362.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:362:2: 
  360.   	if ((x == NULL) || (x->cert_info == NULL))
  361.   		return(NULL);
  362. > 	return(X509_PUBKEY_get(x->cert_info->key));
  363.   	}
  364.   

crypto/asn1/x_pubkey.c:224:1: start of procedure X509_PUBKEY_get()
    222.   	}
    223.   
    224. > EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
    225.   	{
    226.   	EVP_PKEY *ret=NULL;

crypto/asn1/x_pubkey.c:226:2: 
    224.   EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
    225.   	{
    226. > 	EVP_PKEY *ret=NULL;
    227.   	long j;
    228.   	int type;

crypto/asn1/x_pubkey.c:235:6: Taking false branch
    233.   #endif
    234.   
    235.   	if (key == NULL) goto err;
                ^
    236.   
    237.   	if (key->pkey != NULL)

crypto/asn1/x_pubkey.c:237:6: Taking false branch
    235.   	if (key == NULL) goto err;
    236.   
    237.   	if (key->pkey != NULL)
                ^
    238.   		{
    239.   		CRYPTO_add(&key->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);

crypto/asn1/x_pubkey.c:243:6: Taking false branch
    241.   		}
    242.   
    243.   	if (key->public_key == NULL) goto err;
                ^
    244.   
    245.   	type=OBJ_obj2nid(key->algor->algorithm);

crypto/asn1/x_pubkey.c:245:2: 
    243.   	if (key->public_key == NULL) goto err;
    244.   
    245. > 	type=OBJ_obj2nid(key->algor->algorithm);
    246.   	if ((ret = EVP_PKEY_new()) == NULL)
    247.   		{

crypto/objects/obj_dat.c:366:1: start of procedure OBJ_obj2nid()
      364.   	}
      365.   
      366. > int OBJ_obj2nid(const ASN1_OBJECT *a)
      367.   	{
      368.   	ASN1_OBJECT **op;

crypto/objects/obj_dat.c:371:6: Taking false branch
      369.   	ADDED_OBJ ad,*adp;
      370.   
      371.   	if (a == NULL)
                  ^
      372.   		return(NID_undef);
      373.   	if (a->nid != 0)

crypto/objects/obj_dat.c:373:6: Taking true branch
      371.   	if (a == NULL)
      372.   		return(NID_undef);
      373.   	if (a->nid != 0)
                  ^
      374.   		return(a->nid);
      375.   

crypto/objects/obj_dat.c:374:3: 
      372.   		return(NID_undef);
      373.   	if (a->nid != 0)
      374. > 		return(a->nid);
      375.   
      376.   	if (added != NULL)

crypto/objects/obj_dat.c:388:2: return from a call to OBJ_obj2nid
      386.   		return(NID_undef);
      387.   	return((*op)->nid);
      388.   	}
              ^
      389.   
      390.   /* Convert an object name into an ASN1_OBJECT

crypto/asn1/x_pubkey.c:246:6: 
    244.   
    245.   	type=OBJ_obj2nid(key->algor->algorithm);
    246. > 	if ((ret = EVP_PKEY_new()) == NULL)
    247.   		{
    248.   		X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);

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)

crypto/asn1/x_pubkey.c:246:6: Taking true branch
    244.   
    245.   	type=OBJ_obj2nid(key->algor->algorithm);
    246.   	if ((ret = EVP_PKEY_new()) == NULL)
                ^
    247.   		{
    248.   		X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);

crypto/asn1/x_pubkey.c:248:3: 
    246.   	if ((ret = EVP_PKEY_new()) == NULL)
    247.   		{
    248. > 		X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);
    249.   		goto err;
    250.   		}

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/asn1/x_pubkey.c:335:1: 
    333.   	CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY);
    334.   	return(ret);
    335. > err:
    336.   	if (ret != NULL)
    337.   		EVP_PKEY_free(ret);

crypto/asn1/x_pubkey.c:336:6: Taking false branch
    334.   	return(ret);
    335.   err:
    336.   	if (ret != NULL)
                ^
    337.   		EVP_PKEY_free(ret);
    338.   	return(NULL);

crypto/asn1/x_pubkey.c:338:2: 
    336.   	if (ret != NULL)
    337.   		EVP_PKEY_free(ret);
    338. > 	return(NULL);
    339.   	}
    340.   

crypto/asn1/x_pubkey.c:339:2: return from a call to X509_PUBKEY_get
    337.   		EVP_PKEY_free(ret);
    338.   	return(NULL);
    339.   	}
            ^
    340.   
    341.   /* Now two pseudo ASN1 routines that take an EVP_PKEY structure

crypto/x509/x509_cmp.c:363:2: return from a call to X509_get_pubkey
  361.   		return(NULL);
  362.   	return(X509_PUBKEY_get(x->cert_info->key));
  363.   	}
          ^
  364.   
  365.   ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)

ssl/s3_clnt.c:2306:2: Skipping X509_certificate_type(): empty list of specs
2304.   #endif
2305.   	pkey=X509_get_pubkey(sc->peer_pkeys[idx].x509);
2306.   	i=X509_certificate_type(sc->peer_pkeys[idx].x509,pkey);
         ^
2307.   	EVP_PKEY_free(pkey);
2308.   

ssl/s3_clnt.c:2307:2: 
2305.   	pkey=X509_get_pubkey(sc->peer_pkeys[idx].x509);
2306.   	i=X509_certificate_type(sc->peer_pkeys[idx].x509,pkey);
2307. > 	EVP_PKEY_free(pkey);
2308.   
2309.   	
