aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-02-19 18:44:51 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-02-19 18:45:56 +0100
commita09f101f147f2313bc727371f8f1e44dc886d330 (patch)
tree4ea5f409ed1b7a1825a4724bf56505e4fc71589c
parente0b8d459b189ee2b7e95a47b217e4b02bfb523b3 (diff)
Fix #650: CKey::SetSecret BIGNUM leak
-rw-r--r--src/key.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/key.h b/src/key.h
index 9e92897e26..a57143b7d9 100644
--- a/src/key.h
+++ b/src/key.h
@@ -141,10 +141,13 @@ public:
if (vchSecret.size() != 32)
throw key_error("CKey::SetSecret() : secret must be 32 bytes");
BIGNUM *bn = BN_bin2bn(&vchSecret[0],32,BN_new());
- if (bn == NULL)
+ if (bn == NULL)
throw key_error("CKey::SetSecret() : BN_bin2bn failed");
if (!EC_KEY_regenerate_key(pkey,bn))
+ {
+ BN_clear_free(bn);
throw key_error("CKey::SetSecret() : EC_KEY_regenerate_key failed");
+ }
BN_clear_free(bn);
fSet = true;
if (fCompressed || fCompressedPubKey)