Skip to content

Commit d3e8f9b

Browse files
authored
const-oid: fix encoder base128_len calculation
Fixes #1752
1 parent 3552be9 commit d3e8f9b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

const-oid/src/encoder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ impl<const MAX_SIZE: usize> Encoder<MAX_SIZE> {
119119
/// Compute the length of an arc when encoded in base 128.
120120
const fn base128_len(arc: Arc) -> usize {
121121
match arc {
122-
0..=0x7f => 1,
123-
0x80..=0x3fff => 2,
124-
0x4000..=0x1fffff => 3,
125-
0x200000..=0x1fffffff => 4,
122+
0..=0x7f => 1, // up to 7 bits
123+
0x80..=0x3fff => 2, // up to 14 bits
124+
0x4000..=0x1fffff => 3, // up to 21 bits
125+
0x200000..=0x0fffffff => 4, // up to 28 bits
126126
_ => 5,
127127
}
128128
}

const-oid/tests/proptests.proptest-regressions

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ cc d90305406041ea5e4cf4d9e7849cad03391db1869d0b1329f60ccbf1fabaee91 # shrinks to
1111
cc 8ed8dde35d12a2c8e10cdde6d591a8f17f0cd6d6fdf90f1582536401364623bf # shrinks to s = "0.00"
1212
cc ba5e3e3dc1a64870477e82054bbf6d8272f8b0d0c9094115bf7e8b5ff59f3c63 # shrinks to s = "00.1.1"
1313
cc d211e943da9a0e3d0ee5097899b2435f784ca2b3d2f8d4790aae3744823a268a # shrinks to s = "1.1.1.60817410.1"
14+
cc 61bdeaa6cfc6707a0c4f3e9c6165d99d28042e78acb29b0ca7f747c169e83e74 # shrinks to s = "1.1.1.270000000"

0 commit comments

Comments
 (0)