Fix memory leak on exception in Key::SignCompact

This commit is contained in:
Daniel Larimer 2013-05-19 15:46:11 -04:00
parent 173601705c
commit a9280652ce

View File

@ -328,7 +328,10 @@ bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
} }
if (nRecId == -1) if (nRecId == -1)
{
ECDSA_SIG_free(sig);
throw key_error("CKey::SignCompact() : unable to construct recoverable key"); throw key_error("CKey::SignCompact() : unable to construct recoverable key");
}
vchSig[0] = nRecId+27+(fCompressedPubKey ? 4 : 0); vchSig[0] = nRecId+27+(fCompressedPubKey ? 4 : 0);
BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]); BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]);