BigInteger: guard against self-assignment
Related-to: #404. Suggested-by: @cosinekitty
This commit is contained in:
parent
3cf7228f46
commit
afbc0406f0
@ -54,8 +54,10 @@ public:
|
|||||||
|
|
||||||
BigInteger& operator=(const BigInteger &rhs)
|
BigInteger& operator=(const BigInteger &rhs)
|
||||||
{
|
{
|
||||||
count_ = rhs.count_;
|
if (this != &rhs) {
|
||||||
std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
|
count_ = rhs.count_;
|
||||||
|
std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user