Skip to content

Commit

Permalink
Added self-assignment guards or comment indicating why the check is n…
Browse files Browse the repository at this point in the history
…ot needed
  • Loading branch information
noloader committed Jul 30, 2015
1 parent 77206ba commit 8293570
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions algparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x)

AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
{
// Should this be guarded for operations on itself??? This class befuddles me at times...
m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
return *this;
}
Expand Down
8 changes: 5 additions & 3 deletions ec2n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,11 @@ const EC2N::Point& EC2N::Double(const Point &P) const
/*
EcPrecomputation<EC2N>& EcPrecomputation<EC2N>::operator=(const EcPrecomputation<EC2N> &rhs)
{
m_ec = rhs.m_ec;
m_ep = rhs.m_ep;
m_ep.m_group = m_ec.get();
if (this != &rhs)
{
DL_GroupPrecomputation::operator=(rhs);
m_ec = rhs.m_ec;
}
return *this;
}
Expand Down
1 change: 1 addition & 0 deletions gf2n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ unsigned int PolynomialMod2::Parity() const

PolynomialMod2& PolynomialMod2::operator=(const PolynomialMod2& t)
{
// Assign guards for self-assignment
reg.Assign(t.reg);
return *this;
}
Expand Down
10 changes: 5 additions & 5 deletions queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,17 +428,17 @@ byte * ByteQueue::CreatePutSpace(size_t &size)

ByteQueue & ByteQueue::operator=(const ByteQueue &rhs)
{
if (this == &rhs) return *this;

Destroy();
CopyFrom(rhs);
if (this != &rhs)
{
Destroy();
CopyFrom(rhs);
}
return *this;
}

bool ByteQueue::operator==(const ByteQueue &rhs) const
{
const lword currentSize = CurrentSize();

if (currentSize != rhs.CurrentSize())
return false;

Expand Down
1 change: 1 addition & 0 deletions secblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ class SecBlock

SecBlock<T, A>& operator=(const SecBlock<T, A> &t)
{
// Assign guards for self-assignment
Assign(t);
return *this;
}
Expand Down

0 comments on commit 8293570

Please sign in to comment.