diff --git a/libdevcore/Common.h b/libdevcore/Common.h index b7eca90f6..ce637a2a6 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -92,7 +92,15 @@ public: explicit secure_vector(vector_ref _c): m_data(_c.data(), _c.data() + _c.size()) {} ~secure_vector() { ref().cleanse(); } - secure_vector& operator=(secure_vector const& _c) { ref().cleanse(); m_data = _c.m_data; return *this; } + secure_vector& operator=(secure_vector const& _c) + { + if (&_c == this) + return *this; + + ref().cleanse(); + m_data = _c.m_data; + return *this; + } std::vector& writable() { clear(); return m_data; } std::vector const& makeInsecure() const { return m_data; } diff --git a/libdevcore/Worker.h b/libdevcore/Worker.h index fbc4d7042..23c90ab78 100644 --- a/libdevcore/Worker.h +++ b/libdevcore/Worker.h @@ -54,7 +54,12 @@ protected: Worker(Worker&& _m) { std::swap(m_name, _m.m_name); } /// Move-assignment. - Worker& operator=(Worker&& _m) { std::swap(m_name, _m.m_name); return *this; } + Worker& operator=(Worker&& _m) + { + assert(&_m != this); + std::swap(m_name, _m.m_name); + return *this; + } virtual ~Worker() { terminate(); } diff --git a/libethereum/Block.cpp b/libethereum/Block.cpp index a57ded73d..1c8dc1b21 100644 --- a/libethereum/Block.cpp +++ b/libethereum/Block.cpp @@ -80,6 +80,9 @@ Block::Block(Block const& _s): Block& Block::operator=(Block const& _s) { + if (&_s == this) + return *this; + m_state = _s.m_state; m_transactions = _s.m_transactions; m_receipts = _s.m_receipts; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index bd5feacb0..5258e0668 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -136,6 +136,9 @@ void State::paranoia(std::string const& _when, bool _enforceRefs) const State& State::operator=(State const& _s) { + if (&_s == this) + return *this; + m_db = _s.m_db; m_state.open(&m_db, _s.m_state.root(), Verification::Skip); m_cache = _s.m_cache; diff --git a/libethereum/TransactionQueue.cpp b/libethereum/TransactionQueue.cpp index aeeb35214..bf8e14a27 100644 --- a/libethereum/TransactionQueue.cpp +++ b/libethereum/TransactionQueue.cpp @@ -402,4 +402,3 @@ void TransactionQueue::verifierBody() } } } - diff --git a/libethereum/TransactionQueue.h b/libethereum/TransactionQueue.h index 9c8283aa2..b7af75013 100644 --- a/libethereum/TransactionQueue.h +++ b/libethereum/TransactionQueue.h @@ -140,7 +140,14 @@ private: UnverifiedTransaction() {} UnverifiedTransaction(bytesConstRef const& _t, h512 const& _nodeId): transaction(_t.toBytes()), nodeId(_nodeId) {} UnverifiedTransaction(UnverifiedTransaction&& _t): transaction(std::move(_t.transaction)) {} - UnverifiedTransaction& operator=(UnverifiedTransaction&& _other) { transaction = std::move(_other.transaction); nodeId = std::move(_other.nodeId); return *this; } + UnverifiedTransaction& operator=(UnverifiedTransaction&& _other) + { + assert(&_other != this); + + transaction = std::move(_other.transaction); + nodeId = std::move(_other.nodeId); + return *this; + } UnverifiedTransaction(UnverifiedTransaction const&) = delete; UnverifiedTransaction& operator=(UnverifiedTransaction const&) = delete; diff --git a/libethereum/VerifiedBlock.h b/libethereum/VerifiedBlock.h index 8bac12f90..fb96c084c 100644 --- a/libethereum/VerifiedBlock.h +++ b/libethereum/VerifiedBlock.h @@ -58,6 +58,8 @@ struct VerifiedBlock VerifiedBlock& operator=(VerifiedBlock&& _other) { + assert(&_other != this); + verified = (std::move(_other.verified)); blockData = (std::move(_other.blockData)); return *this; diff --git a/libevmasm/SourceLocation.h b/libevmasm/SourceLocation.h index 35e3c0318..b8b57b609 100644 --- a/libevmasm/SourceLocation.h +++ b/libevmasm/SourceLocation.h @@ -41,8 +41,21 @@ struct SourceLocation SourceLocation(): start(-1), end(-1) { } SourceLocation(SourceLocation const& _other): - start(_other.start), end(_other.end), sourceName(_other.sourceName) {} - SourceLocation& operator=(SourceLocation const& _other) { start = _other.start; end = _other.end; sourceName = _other.sourceName; return *this;} + start(_other.start), + end(_other.end), + sourceName(_other.sourceName) + {} + + SourceLocation& operator=(SourceLocation const& _other) + { + if (&_other == this) + return *this; + + start = _other.start; + end = _other.end; + sourceName = _other.sourceName; + return *this; + } bool operator==(SourceLocation const& _other) const { return start == _other.start && end == _other.end;} bool operator!=(SourceLocation const& _other) const { return !operator==(_other); } diff --git a/libp2p/Common.h b/libp2p/Common.h index e6411ce67..9caa9c4c7 100644 --- a/libp2p/Common.h +++ b/libp2p/Common.h @@ -224,7 +224,13 @@ class DeadlineOps ~DeadlineOp() {} DeadlineOp(DeadlineOp&& _s): m_timer(_s.m_timer.release()) {} - DeadlineOp& operator=(DeadlineOp&& _s) { m_timer.reset(_s.m_timer.release()); return *this; } + DeadlineOp& operator=(DeadlineOp&& _s) + { + assert(&_s != this); + + m_timer.reset(_s.m_timer.release()); + return *this; + } bool expired() { Guard l(x_timer); return m_timer->expires_from_now().total_nanoseconds() <= 0; } void wait() { Guard l(x_timer); m_timer->wait(); } diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 744362fb7..6a8d33dcd 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -79,6 +79,8 @@ pair const* StorageOffsets::getOffset(size_t _index) const MemberList& MemberList::operator=(MemberList&& _other) { + assert(&_other != this); + m_memberTypes = std::move(_other.m_memberTypes); m_storageOffsets = std::move(_other.m_storageOffsets); return *this;