aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-06-23 17:47:48 +0100
committerMark Haines <mark.haines@matrix.org>2015-06-23 17:47:48 +0100
commit8bf32c3248fdf0105e9c8d1a3ad2d11e1747f165 (patch)
treefa2e70d784f923ebb3b4581f58a4b88f7eed07b0 /src
parent10e7e8123dac04d62897f29cdbd17e397cc2e854 (diff)
Fix bug encoding integers larger than 128
Diffstat (limited to 'src')
-rw-r--r--src/message.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/message.cpp b/src/message.cpp
index 7eea4c2..343b094 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -21,7 +21,7 @@ std::size_t varint_length(
T value
) {
std::size_t result = 1;
- while (value > 128U) {
+ while (value >= 128U) {
++result;
value >>= 7;
}
@@ -34,8 +34,9 @@ std::uint8_t * varint_encode(
std::uint8_t * output,
T value
) {
- while (value > 128U) {
+ while (value >= 128U) {
*(output++) = (0x7F & value) | 0x80;
+ value >>= 7;
}
(*output++) = value;
return output;