Skip to content

Commit c35215d

Browse files
committed
Fix #15 by working with 64 bit integers as intended for cut math, not usize
1 parent 6b4d076 commit c35215d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/enc/backward_references.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,9 @@ fn TestStaticDictionaryItem(dictionary: &BrotliDictionary,
11261126
return 0i32;
11271127
}
11281128
{
1129-
let cut: usize = len.wrapping_sub(matchlen);
1129+
let cut: u64 = len.wrapping_sub(matchlen) as u64;
11301130
let transform_id: usize =
1131-
(cut << 2i32).wrapping_add(kCutoffTransforms as usize >> cut.wrapping_mul(6) & 0x3f);
1131+
(cut << 2i32).wrapping_add(kCutoffTransforms as u64 >> cut.wrapping_mul(6) & 0x3f) as usize;
11321132
backward = max_backward.wrapping_add(dist)
11331133
.wrapping_add(1usize)
11341134
.wrapping_add(transform_id << (*dictionary).size_bits_by_length[len] as (i32));

0 commit comments

Comments
 (0)