X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fbignum.h;h=acba29a1513ebdefd5783872e8646be723453a7f;hb=24f4884cdf5b4a68a3996238995ac0846dae9126;hp=f37d7edd8b65be732478afa2f74a2b49334d0bf5;hpb=59b5e172f9fed2d27202168630550e21ef995105;p=novacoin.git diff --git a/src/bignum.h b/src/bignum.h index f37d7ed..acba29a 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -59,19 +59,22 @@ public: CBigNum(const CBigNum& b) { - bn = BN_new(); - if (!BN_copy(bn, b.bn)) + BIGNUM *dup = BN_dup(b.bn); + if (!dup) { - BN_clear_free(bn); - throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed"); + throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_dup failed"); } + bn = dup; } CBigNum& operator=(const CBigNum& b) { - bn = BN_new(); - if (!BN_copy(bn, b.bn)) - throw bignum_error("CBigNum::operator= : BN_copy failed"); + BIGNUM *dup = BN_dup(b.bn); + if (!dup) + { + throw bignum_error("CBigNum::operator= : BN_dup failed"); + } + bn = dup; return (*this); } @@ -465,7 +468,11 @@ public: return ToString(16); } - BIGNUM* get() const { + const BIGNUM* get() const { + return bn; + } + + BIGNUM* get() { return bn; }