Skip to content

Commit

Permalink
BigInteger: guard against self-assignment
Browse files Browse the repository at this point in the history
Related-to: Tencent#404.
Suggested-by: @cosinekitty
  • Loading branch information
pah committed Aug 13, 2015
1 parent 3cf7228 commit afbc040
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/rapidjson/internal/biginteger.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ class BigInteger {

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;
}

Expand Down

0 comments on commit afbc040

Please # to comment.