X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fbignum.h;h=acba29a1513ebdefd5783872e8646be723453a7f;hb=24f4884cdf5b4a68a3996238995ac0846dae9126;hp=f1ec8d4368fbe873c7344e3bf9061b0cb1668abc;hpb=d9a9ab764d542fe29e177ff600eff108269d0a57;p=novacoin.git diff --git a/src/bignum.h b/src/bignum.h index f1ec8d4..acba29a 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -59,18 +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) { - 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); } @@ -464,7 +468,11 @@ public: return ToString(16); } - BIGNUM* get() const { + const BIGNUM* get() const { + return bn; + } + + BIGNUM* get() { return bn; }