From 74fb677a32b492aff51b0d9bf00adacc9d8ad93f Mon Sep 17 00:00:00 2001 From: Ivan Kalinin Date: Wed, 16 Oct 2024 00:01:39 +0200 Subject: [PATCH] fix: use proper `max_roots` value in boc decoder debug assert --- src/boc/de.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/boc/de.rs b/src/boc/de.rs index 5b89c498..9eab4c57 100644 --- a/src/boc/de.rs +++ b/src/boc/de.rs @@ -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