Browse Source

Replaced all asserts in RLP with exceptions

cl-refactor
Christoph Jentzsch 10 years ago
parent
commit
b8b878ebba
  1. 3
      libdevcore/RLP.cpp
  2. 4
      libdevcore/RLP.h

3
libdevcore/RLP.cpp

@ -176,7 +176,8 @@ void RLPStream::noteAppended(unsigned _itemCount)
// cdebug << "noteAppended(" << _itemCount << ")";
while (m_listStack.size())
{
assert(m_listStack.back().first >= _itemCount);
if (m_listStack.back().first < _itemCount)
BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("itemCount too large"));
m_listStack.back().first -= _itemCount;
if (m_listStack.back().first)
break;

4
libdevcore/RLP.h

@ -361,10 +361,10 @@ public:
void clear() { m_out.clear(); m_listStack.clear(); }
/// Read the byte stream.
bytes const& out() const { assert(m_listStack.empty()); return m_out; }
bytes const& out() const { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); return m_out; }
/// Swap the contents of the output stream out for some other byte array.
void swapOut(bytes& _dest) { assert(m_listStack.empty()); swap(m_out, _dest); }
void swapOut(bytes& _dest) { if(!m_listStack.empty()) BOOST_THROW_EXCEPTION(RLPException() << errinfo_comment("listStack is not empty")); swap(m_out, _dest); }
private:
void noteAppended(unsigned _itemCount = 1);

Loading…
Cancel
Save