From 173601705ccf189fd83e3854f71f6a872c6faeda Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Sun, 19 May 2013 12:45:52 -0400 Subject: [PATCH 1/2] fix memory leak in CKey::SetCompactSignature() --- src/key.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/key.cpp b/src/key.cpp index 20114e6bb..74b2797d8 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -367,6 +367,7 @@ bool CKey::SetCompactSignature(uint256 hash, const std::vector& v ECDSA_SIG_free(sig); return true; } + ECDSA_SIG_free(sig); return false; } From a9280652ce61ddbbecfe16e18e1e464bb1f5d34d Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Sun, 19 May 2013 15:46:11 -0400 Subject: [PATCH 2/2] Fix memory leak on exception in Key::SignCompact --- src/key.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/key.cpp b/src/key.cpp index 74b2797d8..75114c6af 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -328,7 +328,10 @@ bool CKey::SignCompact(uint256 hash, std::vector& 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]);