Skip to content

Commit

Permalink
fix: use proper max_roots value in boc decoder debug assert
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Oct 15, 2024
1 parent 175019b commit 74fb677
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/boc/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,14 @@ impl<'a> BocHeader<'a> {
return Err(Error::TooFewRootCells);
}
}
if unlikely(root_count > options.max_roots.unwrap_or(MAX_ROOTS)) {
return Err(Error::TooManyRootCells);

{
let max_roots = options.max_roots.unwrap_or(MAX_ROOTS);
if unlikely(root_count > max_roots) {
return Err(Error::TooManyRootCells);
}
debug_assert!(absent_count == 0 && (1..=max_roots).contains(&root_count))
}
debug_assert!(absent_count == 0 && (1..=MAX_ROOTS).contains(&root_count));

// SAFETY: we have already requested at least {ref_size}*3+{offset_size}
// and {ref_size} is in range 1..=8
Expand Down

0 comments on commit 74fb677

Please sign in to comment.