crypto/x509/x509_req.c:123: error: NULL_DEREFERENCE
  pointer `xk` last assigned on line 122 could be null and is dereferenced by call to `EVP_PKEY_cmp()` at line 123, column 10.
Showing all 12 steps of the trace


crypto/x509/x509_req.c:117:1: start of procedure X509_REQ_check_private_key()
115.   	}
116.   
117. > int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)
118.   	{
119.   	EVP_PKEY *xk=NULL;

crypto/x509/x509_req.c:119:2: 
117.   int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)
118.   	{
119. > 	EVP_PKEY *xk=NULL;
120.   	int ok=0;
121.   

crypto/x509/x509_req.c:120:2: 
118.   	{
119.   	EVP_PKEY *xk=NULL;
120. > 	int ok=0;
121.   
122.   	xk=X509_REQ_get_pubkey(x);

crypto/x509/x509_req.c:122:2: 
120.   	int ok=0;
121.   
122. > 	xk=X509_REQ_get_pubkey(x);
123.   	switch (EVP_PKEY_cmp(xk, k))
124.   		{

crypto/x509/x509_req.c:110:1: start of procedure X509_REQ_get_pubkey()
  108.   	}
  109.   
  110. > EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req)
  111.   	{
  112.   	if ((req == NULL) || (req->req_info == NULL))

crypto/x509/x509_req.c:112:7: Taking false branch
  110.   EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req)
  111.   	{
  112.   	if ((req == NULL) || (req->req_info == NULL))
               ^
  113.   		return(NULL);
  114.   	return(X509_PUBKEY_get(req->req_info->pubkey));

crypto/x509/x509_req.c:112:24: Taking true branch
  110.   EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req)
  111.   	{
  112.   	if ((req == NULL) || (req->req_info == NULL))
                                ^
  113.   		return(NULL);
  114.   	return(X509_PUBKEY_get(req->req_info->pubkey));

crypto/x509/x509_req.c:113:3: 
  111.   	{
  112.   	if ((req == NULL) || (req->req_info == NULL))
  113. > 		return(NULL);
  114.   	return(X509_PUBKEY_get(req->req_info->pubkey));
  115.   	}

crypto/x509/x509_req.c:115:2: return from a call to X509_REQ_get_pubkey
  113.   		return(NULL);
  114.   	return(X509_PUBKEY_get(req->req_info->pubkey));
  115.   	}
          ^
  116.   
  117.   int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)

crypto/x509/x509_req.c:123:2: 
121.   
122.   	xk=X509_REQ_get_pubkey(x);
123. > 	switch (EVP_PKEY_cmp(xk, k))
124.   		{
125.   	case 1:

crypto/evp/p_lib.c:159:1: start of procedure EVP_PKEY_cmp()
  157.   	}
  158.   
  159. > int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
  160.   	{
  161.   	if (a->type != b->type)

crypto/evp/p_lib.c:161:6: 
  159.   int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
  160.   	{
  161. > 	if (a->type != b->type)
  162.   		return -1;
  163.   

int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)
	{
	EVP_PKEY *xk=NULL;
	int ok=0;
	xk=X509_REQ_get_pubkey(x);
	switch (EVP_PKEY_cmp(xk, k))
		{
	case 1:
		ok=1;
		break;
	case 0:
		X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,X509_R_KEY_VALUES_MISMATCH);
		break;
	case -1:
		X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,X509_R_KEY_TYPE_MISMATCH);
		break;
	case -2:
#ifndef OPENSSL_NO_EC
		if (k->type == EVP_PKEY_EC)
			{
			X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, ERR_R_EC_LIB);
			break;
			}
#endif
#ifndef OPENSSL_NO_DH
		if (k->type == EVP_PKEY_DH)
			{
			X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,X509_R_CANT_CHECK_DH_KEY);
			break;
			}
#endif
	        X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,X509_R_UNKNOWN_KEY_TYPE);
		}
	EVP_PKEY_free(xk);
	return(ok);
	}
['int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k)\n\t{\n\tEVP_PKEY *xk=NULL;\n\tint ok=0;\n\txk=X509_REQ_get_pubkey(x);\n\tswitch (EVP_PKEY_cmp(xk, k))\n\t\t{\n\tcase 1:\n\t\tok=1;\n\t\tbreak;\n\tcase 0:\n\t\tX509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,X509_R_KEY_VALUES_MISMATCH);\n\t\tbreak;\n\tcase -1:\n\t\tX509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,X509_R_KEY_TYPE_MISMATCH);\n\t\tbreak;\n\tcase -2:\n#ifndef OPENSSL_NO_EC\n\t\tif (k->type == EVP_PKEY_EC)\n\t\t\t{\n\t\t\tX509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, ERR_R_EC_LIB);\n\t\t\tbreak;\n\t\t\t}\n#endif\n#ifndef OPENSSL_NO_DH\n\t\tif (k->type == EVP_PKEY_DH)\n\t\t\t{\n\t\t\tX509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,X509_R_CANT_CHECK_DH_KEY);\n\t\t\tbreak;\n\t\t\t}\n#endif\n\t        X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY,X509_R_UNKNOWN_KEY_TYPE);\n\t\t}\n\tEVP_PKEY_free(xk);\n\treturn(ok);\n\t}', 'EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req)\n\t{\n\tif ((req == NULL) || (req->req_info == NULL))\n\t\treturn(NULL);\n\treturn(X509_PUBKEY_get(req->req_info->pubkey));\n\t}', 'int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)\n\t{\n\tif (a->type != b->type)\n\t\treturn -1;\n\tif (a->ameth)\n\t\t{\n\t\tint ret;\n\t\tif (a->ameth->param_cmp)\n\t\t\t{\n\t\t\tret = a->ameth->param_cmp(a, b);\n\t\t\tif (ret <= 0)\n\t\t\t\treturn ret;\n\t\t\t}\n\t\tif (a->ameth->pub_cmp)\n\t\t\treturn a->ameth->pub_cmp(a, b);\n\t\t}\n\treturn -2;\n\t}']