Skip to content

Commit

Permalink
Human encoding: Words are <= 2^31 bits long
Browse files Browse the repository at this point in the history
Words are <= 32 levels deep.
Depth n means a bit length of 2^{n - 1}.
1 << 32 also causes an overflow on 32-bit systems.
  • Loading branch information
uncomputable committed Dec 5, 2023
1 parent b0cc9d2 commit 01f709a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/human_encoding/parse/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ fn grammar<J: Jet + 'static>() -> Grammar<Ast<J>> {
let (data, bit_length, position) = toks[1].expect_literal();
let mut iter = BitIter::from(data);

if bit_length.count_ones() != 1 || bit_length > 1 << 32 {
if bit_length.count_ones() != 1 || bit_length > 1 << 31 {
return Ast::Error(ErrorSet::single(
position,
Error::BadWordLength { bit_length },
Expand Down

0 comments on commit 01f709a

Please sign in to comment.