From a053396e69e96c02ea3b79eec6231ec9d4b5e75d Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 29 Nov 2022 10:38:31 -0800 Subject: [PATCH] WIP. --- src/frontend.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend.rs b/src/frontend.rs index 492fb91..d7d4221 100644 --- a/src/frontend.rs +++ b/src/frontend.rs @@ -233,7 +233,13 @@ fn handle_payload<'a>( } let table_items = module.table_mut(table).func_elements.as_mut().unwrap(); - let new_size = offset + funcs.len(); + let new_size = offset.checked_add(funcs.len()).ok_or_else(|| { + FrontendError::TooLarge(format!( + "Overflowing element offset + length: {} + {}", + offset, + funcs.len() + )) + })?; if new_size > table_items.len() { static MAX_TABLE: usize = 100_000; if new_size > MAX_TABLE {