aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Larimer <dlarimer@gmail.com>2013-05-19 15:46:11 -0400
committerWladimir J. van der Laan <laanwj@gmail.com>2013-12-05 09:15:41 +0100
commit6f21e7317e86cac4f26234116513fa153111032a (patch)
tree547a648ece895bb6d5342e2c01e8a8b474e8ae5b
parentdaf9e4627f5dda2b7afec25bd17f6b75d803269a (diff)
Fix memory leak on exception in Key::SignCompact
-rw-r--r--src/key.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/key.cpp b/src/key.cpp
index 20114e6bb2..af9ffaf792 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -328,7 +328,10 @@ bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
}
if (nRecId == -1)
+ {
+ ECDSA_SIG_free(sig);
throw key_error("CKey::SignCompact() : unable to construct recoverable key");
+ }
vchSig[0] = nRecId+27+(fCompressedPubKey ? 4 : 0);
BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]);