Merge pull request #409 from pah/fix/biginteger-self-assign

BigInteger: guard against self-assignment
This commit is contained in:
Milo Yip 2015-08-14 10:07:18 +08:00
commit 3ede21c356

View File

@ -54,8 +54,10 @@ public:
BigInteger& operator=(const BigInteger &rhs)
{
count_ = rhs.count_;
std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
if (this != &rhs) {
count_ = rhs.count_;
std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
}
return *this;
}