From 1596c0e92e4b182821ce09f4e6e9f567783a72b5 Mon Sep 17 00:00:00 2001 From: Nick Garfield Date: Thu, 30 Mar 2023 13:45:02 +0000 Subject: [PATCH] Replace unsafe arithmetic with checked_add --- lang/syn/src/codegen/program/idl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/syn/src/codegen/program/idl.rs b/lang/syn/src/codegen/program/idl.rs index 5adc5436ea..a389de8539 100644 --- a/lang/syn/src/codegen/program/idl.rs +++ b/lang/syn/src/codegen/program/idl.rs @@ -273,7 +273,7 @@ pub fn idl_accounts_and_functions() -> proc_macro2::TokenStream { anchor_lang::prelude::msg!("Instruction: IdlWrite"); let prev_len: usize = ::std::convert::TryInto::::try_into(accounts.idl.data_len).unwrap(); - let new_len: usize = prev_len + idl_data.len() as usize; + let new_len: usize = prev_len.checked_add(idl_data.len()).unwrap() as usize; accounts.idl.data_len = accounts.idl.data_len.checked_add(::std::convert::TryInto::::try_into(idl_data.len()).unwrap()).unwrap(); use IdlTrailingData;