Skip to content

Commit

Permalink
Merge pull request Tencent#409 from pah/fix/biginteger-self-assign
Browse files Browse the repository at this point in the history
BigInteger: guard against self-assignment
  • Loading branch information
miloyip committed Aug 14, 2015
2 parents 3cf7228 + afbc040 commit 3ede21c
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 3ede21c

Please sign in to comment.