Fix overflow in VarLong

This commit is contained in:
Omar Roth 2019-10-08 09:49:51 -04:00
parent 496a5f34a9
commit 174a36f4ad
No known key found for this signature in database
GPG key ID: B8254FB7EC3D37F2

View file

@ -51,10 +51,10 @@ struct VarLong
def self.to_io(io : IO, value : Int64) def self.to_io(io : IO, value : Int64)
io.write_byte 0x00 if value == 0x00 io.write_byte 0x00 if value == 0x00
value = value.to_u64 value = value.to_u64!
while value != 0 while value != 0
byte = (value & 0x7f).to_u8 byte = (value & 0x7f).to_u8!
value >>= 7 value >>= 7
if value != 0 if value != 0