We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent acb1153 commit 9db9d62Copy full SHA for 9db9d62
src/streams.h
@@ -345,18 +345,16 @@ class CDataStream
345
346
// Read from the beginning of the buffer
347
unsigned int nReadPosNext = nReadPos + nSize;
348
- if (nReadPosNext >= vch.size())
+ if (nReadPosNext > vch.size()) {
349
+ throw std::ios_base::failure("CDataStream::read(): end of data");
350
+ }
351
+ memcpy(pch, &vch[nReadPos], nSize);
352
+ if (nReadPosNext == vch.size())
353
{
- if (nReadPosNext > vch.size())
- {
- throw std::ios_base::failure("CDataStream::read(): end of data");
- }
354
- memcpy(pch, &vch[nReadPos], nSize);
355
nReadPos = 0;
356
vch.clear();
357
return;
358
}
359
360
nReadPos = nReadPosNext;
361
362
0 commit comments