crypto/x509/x509_cmp.c:377: error: NULL_DEREFERENCE
  pointer `xk` last assigned on line 376 could be null and is dereferenced at line 377, column 6.
Showing all 10 steps of the trace


crypto/x509/x509_cmp.c:371:1: start of procedure X509_check_private_key()
369.   	}
370.   
371. > int X509_check_private_key(X509 *x, EVP_PKEY *k)
372.   	{
373.   	EVP_PKEY *xk=NULL;

crypto/x509/x509_cmp.c:373:2: 
371.   int X509_check_private_key(X509 *x, EVP_PKEY *k)
372.   	{
373. > 	EVP_PKEY *xk=NULL;
374.   	int ok=0;
375.   

crypto/x509/x509_cmp.c:374:2: 
372.   	{
373.   	EVP_PKEY *xk=NULL;
374. > 	int ok=0;
375.   
376.   	xk=X509_get_pubkey(x);

crypto/x509/x509_cmp.c:376:2: 
374.   	int ok=0;
375.   
376. > 	xk=X509_get_pubkey(x);
377.   	if (xk->type != k->type)
378.   	    {

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 true 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:361:3: 
  359.   	{
  360.   	if ((x == NULL) || (x->cert_info == NULL))
  361. > 		return(NULL);
  362.   	return(X509_PUBKEY_get(x->cert_info->key));
  363.   	}

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)

crypto/x509/x509_cmp.c:377:6: 
375.   
376.   	xk=X509_get_pubkey(x);
377. > 	if (xk->type != k->type)
378.   	    {
379.   	    X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_TYPE_MISMATCH);

int X509_check_private_key(X509 *x, EVP_PKEY *k)
	{
	EVP_PKEY *xk=NULL;
	int ok=0;
	xk=X509_get_pubkey(x);
	if (xk->type != k->type)
	    {
	    X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_TYPE_MISMATCH);
	    goto err;
	    }
	switch (k->type)
		{
#ifndef OPENSSL_NO_RSA
	case EVP_PKEY_RSA:
		if (BN_cmp(xk->pkey.rsa->n,k->pkey.rsa->n) != 0
		    || BN_cmp(xk->pkey.rsa->e,k->pkey.rsa->e) != 0)
		    {
		    X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_VALUES_MISMATCH);
		    goto err;
		    }
		break;
#endif
#ifndef OPENSSL_NO_DSA
	case EVP_PKEY_DSA:
		if (BN_cmp(xk->pkey.dsa->pub_key,k->pkey.dsa->pub_key) != 0)
		    {
		    X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_VALUES_MISMATCH);
		    goto err;
		    }
		break;
#endif
#ifndef OPENSSL_NO_EC
	case EVP_PKEY_EC:
		{
		int  r = EC_POINT_cmp(xk->pkey.eckey->group,
			xk->pkey.eckey->pub_key,k->pkey.eckey->pub_key,NULL);
		if (r != 0)
			{
			if (r == 1)
				X509err(X509_F_X509_CHECK_PRIVATE_KEY, X509_R_KEY_VALUES_MISMATCH);
			else
				X509err(X509_F_X509_CHECK_PRIVATE_KEY, ERR_R_EC_LIB);
			goto err;
			}
		}
 		break;
#endif
#ifndef OPENSSL_NO_DH
	case EVP_PKEY_DH:
	        X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_CANT_CHECK_DH_KEY);
		goto err;
#endif
	default:
	        X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_UNKNOWN_KEY_TYPE);
		goto err;
		}
	ok=1;
err:
	EVP_PKEY_free(xk);
	return(ok);
	}
['int X509_check_private_key(X509 *x, EVP_PKEY *k)\n\t{\n\tEVP_PKEY *xk=NULL;\n\tint ok=0;\n\txk=X509_get_pubkey(x);\n\tif (xk->type != k->type)\n\t    {\n\t    X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_TYPE_MISMATCH);\n\t    goto err;\n\t    }\n\tswitch (k->type)\n\t\t{\n#ifndef OPENSSL_NO_RSA\n\tcase EVP_PKEY_RSA:\n\t\tif (BN_cmp(xk->pkey.rsa->n,k->pkey.rsa->n) != 0\n\t\t    || BN_cmp(xk->pkey.rsa->e,k->pkey.rsa->e) != 0)\n\t\t    {\n\t\t    X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_VALUES_MISMATCH);\n\t\t    goto err;\n\t\t    }\n\t\tbreak;\n#endif\n#ifndef OPENSSL_NO_DSA\n\tcase EVP_PKEY_DSA:\n\t\tif (BN_cmp(xk->pkey.dsa->pub_key,k->pkey.dsa->pub_key) != 0)\n\t\t    {\n\t\t    X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_KEY_VALUES_MISMATCH);\n\t\t    goto err;\n\t\t    }\n\t\tbreak;\n#endif\n#ifndef OPENSSL_NO_EC\n\tcase EVP_PKEY_EC:\n\t\t{\n\t\tint  r = EC_POINT_cmp(xk->pkey.eckey->group,\n\t\t\txk->pkey.eckey->pub_key,k->pkey.eckey->pub_key,NULL);\n\t\tif (r != 0)\n\t\t\t{\n\t\t\tif (r == 1)\n\t\t\t\tX509err(X509_F_X509_CHECK_PRIVATE_KEY, X509_R_KEY_VALUES_MISMATCH);\n\t\t\telse\n\t\t\t\tX509err(X509_F_X509_CHECK_PRIVATE_KEY, ERR_R_EC_LIB);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n \t\tbreak;\n#endif\n#ifndef OPENSSL_NO_DH\n\tcase EVP_PKEY_DH:\n\t        X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_CANT_CHECK_DH_KEY);\n\t\tgoto err;\n#endif\n\tdefault:\n\t        X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_UNKNOWN_KEY_TYPE);\n\t\tgoto err;\n\t\t}\n\tok=1;\nerr:\n\tEVP_PKEY_free(xk);\n\treturn(ok);\n\t}', 'EVP_PKEY *X509_get_pubkey(X509 *x)\n\t{\n\tif ((x == NULL) || (x->cert_info == NULL))\n\t\treturn(NULL);\n\treturn(X509_PUBKEY_get(x->cert_info->key));\n\t}']