diff --git a/src/encoding.rs b/src/encoding.rs index 0c77123c5..789bb3941 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -27,7 +27,8 @@ pub fn encode_varint(mut value: u64, buf: &mut B) where B: BufMut, { - loop { + // Varints are never more than 10 bytes + for _ in 0..10 { if value < 0x80 { buf.put_u8(value as u8); break;