Commit afbc0406 authored by Philipp A. Hartmann's avatar Philipp A. Hartmann

BigInteger: guard against self-assignment

Related-to: #404.
Suggested-by: @cosinekitty
parent 3cf7228f
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment