diff options
-rw-r--r-- | src/lib/math/bigint/big_ops2.cpp | 4 | ||||
-rw-r--r-- | src/lib/math/bigint/bigint.cpp | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/math/bigint/big_ops2.cpp b/src/lib/math/bigint/big_ops2.cpp index c203f363a..639d87ceb 100644 --- a/src/lib/math/bigint/big_ops2.cpp +++ b/src/lib/math/bigint/big_ops2.cpp @@ -21,7 +21,9 @@ BigInt& BigInt::operator+=(const BigInt& y) const size_t x_sw = sig_words(), y_sw = y.sig_words(); const size_t reg_size = std::max(x_sw, y_sw) + 1; - grow_to(reg_size); + + if(m_reg.size() < reg_size) + grow_to(reg_size); if(sign() == y.sign()) bigint_add2(mutable_data(), reg_size - 1, y.data(), y_sw); diff --git a/src/lib/math/bigint/bigint.cpp b/src/lib/math/bigint/bigint.cpp index b63bd9be8..e5f8974d5 100644 --- a/src/lib/math/bigint/bigint.cpp +++ b/src/lib/math/bigint/bigint.cpp @@ -23,7 +23,7 @@ BigInt::BigInt(uint64_t n) const size_t limbs_needed = sizeof(uint64_t) / sizeof(word); - m_reg.resize(4*limbs_needed); + m_reg.resize(limbs_needed); for(size_t i = 0; i != limbs_needed; ++i) m_reg[i] = ((n >> (i*MP_WORD_BITS)) & MP_WORD_MASK); } |