CDataStream::ignore Throw exception instead of assert on negative nSize.

Previously disk corruption would cause an assert instead of an exception.
This commit is contained in:
Patrick Strateman
2016-04-24 21:59:46 -07:00
committed by Simon
parent f588c5edd6
commit e9d221e764

View File

@@ -241,7 +241,9 @@ public:
CBaseDataStream& ignore(int nSize) CBaseDataStream& ignore(int nSize)
{ {
// Ignore from the beginning of the buffer // Ignore from the beginning of the buffer
assert(nSize >= 0); if (nSize < 0) {
throw std::ios_base::failure("CDataStream::ignore(): nSize negative");
}
unsigned int nReadPosNext = nReadPos + nSize; unsigned int nReadPosNext = nReadPos + nSize;
if (nReadPosNext >= vch.size()) if (nReadPosNext >= vch.size())
{ {