integer-encoding-rs icon indicating copy to clipboard operation
integer-encoding-rs copied to clipboard

fix: decode returns `None` with u64::MAX + 1

Open JayWhite2357 opened this issue 1 year ago • 1 comments

Rationale

[0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x02] is the encoding of u64::MAX. This does not return None when decoding even though it should.

This PR fixes this issue.

Changes

  • u64::decode_var now returns None when a 10th byte is used but is more than 1.
  • A test is added for the above case.

JayWhite2357 avatar Jan 26 '24 15:01 JayWhite2357