Skip to content

Commit 4bf631e

Browse files
pstratemsipa
authored andcommitted
CDataStream::ignore Throw exception instead of assert on negative nSize.
Previously disk corruption would cause an assert instead of an exception.
1 parent 4f87af6 commit 4bf631e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/streams.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ class CDataStream
240240
CDataStream& ignore(int nSize)
241241
{
242242
// Ignore from the beginning of the buffer
243-
assert(nSize >= 0);
243+
if (nSize < 0) {
244+
throw std::ios_base::failure("CDataStream::ignore(): nSize negative");
245+
}
244246
unsigned int nReadPosNext = nReadPos + nSize;
245247
if (nReadPosNext >= vch.size())
246248
{

0 commit comments

Comments
 (0)