ssl/s3_both.c:503: error: NULL_DEREFERENCE
  pointer `pk` last assigned on line 463 could be null and is dereferenced by call to `EVP_PKEY_free()` at line 503, column 12.
Showing all 20 steps of the trace


ssl/s3_both.c:457:1: start of procedure ssl_cert_type()
455.   	}
456.   
457. > int ssl_cert_type(X509 *x, EVP_PKEY *pkey)
458.   	{
459.   	EVP_PKEY *pk;

ssl/s3_both.c:460:2: 
458.   	{
459.   	EVP_PKEY *pk;
460. > 	int ret= -1,i,j;
461.   
462.   	if (pkey == NULL)

ssl/s3_both.c:462:6: Taking true branch
460.   	int ret= -1,i,j;
461.   
462.   	if (pkey == NULL)
            ^
463.   		pk=X509_get_pubkey(x);
464.   	else

ssl/s3_both.c:463:3: 
461.   
462.   	if (pkey == NULL)
463. > 		pk=X509_get_pubkey(x);
464.   	else
465.   		pk=pkey;

crypto/x509/x509_cmp.c:260:1: start of procedure X509_get_pubkey()
  258.   	}
  259.   
  260. > EVP_PKEY *X509_get_pubkey(X509 *x)
  261.   	{
  262.   	if ((x == NULL) || (x->cert_info == NULL))

crypto/x509/x509_cmp.c:262:7: Taking false branch
  260.   EVP_PKEY *X509_get_pubkey(X509 *x)
  261.   	{
  262.   	if ((x == NULL) || (x->cert_info == NULL))
               ^
  263.   		return(NULL);
  264.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:262:22: Taking true branch
  260.   EVP_PKEY *X509_get_pubkey(X509 *x)
  261.   	{
  262.   	if ((x == NULL) || (x->cert_info == NULL))
                              ^
  263.   		return(NULL);
  264.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:263:3: 
  261.   	{
  262.   	if ((x == NULL) || (x->cert_info == NULL))
  263. > 		return(NULL);
  264.   	return(X509_PUBKEY_get(x->cert_info->key));
  265.   	}

crypto/x509/x509_cmp.c:265:2: return from a call to X509_get_pubkey
  263.   		return(NULL);
  264.   	return(X509_PUBKEY_get(x->cert_info->key));
  265.   	}
          ^
  266.   
  267.   int X509_check_private_key(X509 *x, EVP_PKEY *k)

ssl/s3_both.c:466:6: Taking true branch
464.   	else
465.   		pk=pkey;
466.   	if (pk == NULL) goto err;
            ^
467.   
468.   	i=pk->type;

ssl/s3_both.c:502:1: 
500.   		ret= -1;
501.   
502. > err:
503.   	if(!pkey) EVP_PKEY_free(pk);
504.   	return(ret);

ssl/s3_both.c:503:6: Taking true branch
501.   
502.   err:
503.   	if(!pkey) EVP_PKEY_free(pk);
            ^
504.   	return(ret);
505.   	}

ssl/s3_both.c:503:12: 
501.   
502.   err:
503. > 	if(!pkey) EVP_PKEY_free(pk);
504.   	return(ret);
505.   	}

crypto/evp/p_lib.c:286:1: start of procedure EVP_PKEY_free()
  284.   	}
  285.   
  286. > void EVP_PKEY_free(EVP_PKEY *x)
  287.   	{
  288.   	int i;

crypto/evp/p_lib.c:290:6: Taking false branch
  288.   	int i;
  289.   
  290.   	if (x == NULL) return;
              ^
  291.   
  292.   	i=CRYPTO_add(&x->references,-1,CRYPTO_LOCK_EVP_PKEY);

crypto/evp/p_lib.c:292:2: 
  290.   	if (x == NULL) return;
  291.   
  292. > 	i=CRYPTO_add(&x->references,-1,CRYPTO_LOCK_EVP_PKEY);
  293.   #ifdef REF_PRINT
  294.   	REF_PRINT("EVP_PKEY",x);

crypto/cryptlib.c:227:1: start of procedure CRYPTO_add_lock()
    225.   	}
    226.   
    227. > int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
    228.   	     int line)
    229.   	{

crypto/cryptlib.c:232:6: Taking true branch
    230.   	int ret;
    231.   
    232.   	if (add_lock_callback != NULL)
                ^
    233.   		{
    234.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:238:3: Skipping __function_pointer__(): unresolved function pointer
    236.   #endif
    237.   
    238.   		ret=add_lock_callback(pointer,amount,type,file,line);
             ^
    239.   #ifdef LOCK_DEBUG
    240.   		fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",

crypto/cryptlib.c:246:3: 
    244.   			file,line);
    245.   #endif
    246. > 		*pointer=ret;
    247.   		}
    248.   	else
