From c0854473e9b7658cbce06f840d3277b5dad6b7e1 Mon Sep 17 00:00:00 2001 From: blackball Date: Fri, 7 Aug 2015 10:04:45 +0200 Subject: [PATCH] Implement = operator for BigInteger There's a copy constructor, but no '=' operator implemented. This is dangerous. --- include/rapidjson/internal/biginteger.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/internal/biginteger.h b/include/rapidjson/internal/biginteger.h index 512b6f97b..f4d6d1282 100755 --- a/include/rapidjson/internal/biginteger.h +++ b/include/rapidjson/internal/biginteger.h @@ -51,7 +51,14 @@ class BigInteger { if (length > 0) AppendDecimal64(decimals + i, decimals + i + length); } - + + BigInteger& operator=(const BigInteger &rhs) + { + count_ = rhs.count_; + std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type)); + return *this; + } + BigInteger& operator=(uint64_t u) { digits_[0] = u; count_ = 1;