crypto/dh/dh_ameth.c:723: error: UNINITIALIZED_VALUE
  The value read from public_key was never initialized.
Showing all 1 steps of the trace


crypto/dh/dh_ameth.c:723:6: 
721.   		rv = 1;
722.   	err:
723. > 	if (public_key)
724.   		ASN1_INTEGER_free(public_key);
725.   	if (pkpeer)

static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
				X509_ALGOR *alg, ASN1_BIT_STRING *pubkey)
	{
	ASN1_OBJECT *aoid;
	int atype;
	void *aval;
	ASN1_INTEGER *public_key;
	int rv = 0;
	EVP_PKEY *pkpeer = NULL, *pk = NULL;
	DH *dhpeer = NULL;
	const unsigned char *p;
	int plen;
	X509_ALGOR_get0(&aoid, &atype, &aval, alg);
	if (OBJ_obj2nid(aoid) != NID_dhpublicnumber)
		goto err;
	if (atype != V_ASN1_UNDEF && atype == V_ASN1_NULL)
		goto err;
	pk = EVP_PKEY_CTX_get0_pkey(pctx);
	if (!pk)
		goto err;
	if (pk->type != EVP_PKEY_DHX)
		goto err;
	dhpeer = DHparams_dup(pk->pkey.dh);
	plen = ASN1_STRING_length(pubkey);
	p = ASN1_STRING_data(pubkey);
	if (!p || !plen)
		goto err;
	if (!(public_key=d2i_ASN1_INTEGER(NULL, &p, plen)))
		{
		DHerr(DH_F_DH_CMS_SET_PEERKEY, DH_R_DECODE_ERROR);
		goto err;
		}
	if (!(dhpeer->pub_key = ASN1_INTEGER_to_BN(public_key, NULL)))
		{
		DHerr(DH_F_DH_CMS_SET_PEERKEY, DH_R_BN_DECODE_ERROR);
		goto err;
		}
	pkpeer = EVP_PKEY_new();
	if (!pkpeer)
		goto err;
	EVP_PKEY_assign(pkpeer, pk->ameth->pkey_id, dhpeer);
	dhpeer = NULL;
	if (EVP_PKEY_derive_set_peer(pctx, pkpeer) > 0)
		rv = 1;
	err:
	if (public_key)
		ASN1_INTEGER_free(public_key);
	if (pkpeer)
		EVP_PKEY_free(pkpeer);
	if (dhpeer)
		DH_free(dhpeer);
	return rv;
	}
['static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx,\n\t\t\t\tX509_ALGOR *alg, ASN1_BIT_STRING *pubkey)\n\t{\n\tASN1_OBJECT *aoid;\n\tint atype;\n\tvoid *aval;\n\tASN1_INTEGER *public_key;\n\tint rv = 0;\n\tEVP_PKEY *pkpeer = NULL, *pk = NULL;\n\tDH *dhpeer = NULL;\n\tconst unsigned char *p;\n\tint plen;\n\tX509_ALGOR_get0(&aoid, &atype, &aval, alg);\n\tif (OBJ_obj2nid(aoid) != NID_dhpublicnumber)\n\t\tgoto err;\n\tif (atype != V_ASN1_UNDEF && atype == V_ASN1_NULL)\n\t\tgoto err;\n\tpk = EVP_PKEY_CTX_get0_pkey(pctx);\n\tif (!pk)\n\t\tgoto err;\n\tif (pk->type != EVP_PKEY_DHX)\n\t\tgoto err;\n\tdhpeer = DHparams_dup(pk->pkey.dh);\n\tplen = ASN1_STRING_length(pubkey);\n\tp = ASN1_STRING_data(pubkey);\n\tif (!p || !plen)\n\t\tgoto err;\n\tif (!(public_key=d2i_ASN1_INTEGER(NULL, &p, plen)))\n\t\t{\n\t\tDHerr(DH_F_DH_CMS_SET_PEERKEY, DH_R_DECODE_ERROR);\n\t\tgoto err;\n\t\t}\n\tif (!(dhpeer->pub_key = ASN1_INTEGER_to_BN(public_key, NULL)))\n\t\t{\n\t\tDHerr(DH_F_DH_CMS_SET_PEERKEY, DH_R_BN_DECODE_ERROR);\n\t\tgoto err;\n\t\t}\n\tpkpeer = EVP_PKEY_new();\n\tif (!pkpeer)\n\t\tgoto err;\n\tEVP_PKEY_assign(pkpeer, pk->ameth->pkey_id, dhpeer);\n\tdhpeer = NULL;\n\tif (EVP_PKEY_derive_set_peer(pctx, pkpeer) > 0)\n\t\trv = 1;\n\terr:\n\tif (public_key)\n\t\tASN1_INTEGER_free(public_key);\n\tif (pkpeer)\n\t\tEVP_PKEY_free(pkpeer);\n\tif (dhpeer)\n\t\tDH_free(dhpeer);\n\treturn rv;\n\t}']