aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2017-04-21 17:33:22 +0200
committerWladimir J. van der Laan <[email protected]>2017-04-21 17:34:00 +0200
commit1428f3030d99a4b9757494b4b36801ef473bacce (patch)
tree46011faf117443dfac4a7ae47b4eff238afd7594 /src
parentMerge #10223: Tests: Refactor to create witness script creation function (diff)
parentFix some empty vector references (diff)
downloaddiscoin-1428f3030d99a4b9757494b4b36801ef473bacce.tar.xz
discoin-1428f3030d99a4b9757494b4b36801ef473bacce.zip
Merge #10250: Fix some empty vector references
f478d98 Fix some empty vector references (Pieter Wuille) Tree-SHA512: a22022b9060cd39f8d349e8dd24490614c0028eae2fbc7186d0d26b1d47529049b2daee41f093c0722130274a0b6f7f8671c2295c8cb4a97028771eaff080734
Diffstat (limited to 'src')
-rw-r--r--src/streams.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/streams.h b/src/streams.h
index 1387b9cf5..8dc5a19ea 100644
--- a/src/streams.h
+++ b/src/streams.h
@@ -248,7 +248,8 @@ public:
void insert(iterator it, std::vector<char>::const_iterator first, std::vector<char>::const_iterator last)
{
- assert(last - first >= 0);
+ if (last == first) return;
+ assert(last - first > 0);
if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos)
{
// special case for inserting at the front when there's room
@@ -261,7 +262,8 @@ public:
void insert(iterator it, const char* first, const char* last)
{
- assert(last - first >= 0);
+ if (last == first) return;
+ assert(last - first > 0);
if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos)
{
// special case for inserting at the front when there's room
@@ -339,6 +341,8 @@ public:
void read(char* pch, size_t nSize)
{
+ if (nSize == 0) return;
+
// Read from the beginning of the buffer
unsigned int nReadPosNext = nReadPos + nSize;
if (nReadPosNext >= vch.size())