diff options
| author | Jeff Garzik <[email protected]> | 2012-07-03 19:50:06 -0700 |
|---|---|---|
| committer | Jeff Garzik <[email protected]> | 2012-07-03 19:50:06 -0700 |
| commit | 3ee48ba20a5ef6fd41941dc5089b0279eff30aea (patch) | |
| tree | 2b8a266cee29f353d356dfc5960127c50256a32c /src | |
| parent | Merge pull request #1545 from TheBlueMatt/diffsendbuffer (diff) | |
| parent | Fix signed/unsigned warnings in {script,serialize}.h (fixes #1541) (diff) | |
| download | discoin-3ee48ba20a5ef6fd41941dc5089b0279eff30aea.tar.xz discoin-3ee48ba20a5ef6fd41941dc5089b0279eff30aea.zip | |
Merge pull request #1548 from TheBlueMatt/warnings
Fix signed/unsigned warnings in {script,serialize}.h (fixes #1541)
Diffstat (limited to 'src')
| -rw-r--r-- | src/script.h | 2 | ||||
| -rw-r--r-- | src/serialize.h | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/script.h b/src/script.h index d490cd182..e2b83bd6e 100644 --- a/src/script.h +++ b/src/script.h @@ -452,7 +452,7 @@ public: memcpy(&nSize, &pc[0], 4); pc += 4; } - if (end() - pc < nSize) + if (end() - pc < 0 || (unsigned int)(end() - pc) < nSize) return false; if (pvchRet) pvchRet->assign(pc, pc + nSize); diff --git a/src/serialize.h b/src/serialize.h index 349a40bfe..abc4f04a0 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -809,7 +809,8 @@ public: void insert(iterator it, const_iterator first, const_iterator last) { - if (it == vch.begin() + nReadPos && last - first <= nReadPos) + 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 nReadPos -= (last - first); @@ -821,7 +822,8 @@ public: void insert(iterator it, std::vector<char>::const_iterator first, std::vector<char>::const_iterator last) { - if (it == vch.begin() + nReadPos && last - first <= nReadPos) + 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 nReadPos -= (last - first); @@ -834,7 +836,8 @@ public: #if !defined(_MSC_VER) || _MSC_VER >= 1300 void insert(iterator it, const char* first, const char* last) { - if (it == vch.begin() + nReadPos && last - first <= nReadPos) + 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 nReadPos -= (last - first); |