Skip to content

Commit

Permalink
Replace unsafe arithmetic with checked_add (#2448)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgarfield authored Mar 30, 2023
1 parent 9a07508 commit fbd0688
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lang/syn/src/codegen/program/idl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>::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::<u32>::try_into(idl_data.len()).unwrap()).unwrap();

use IdlTrailingData;
Expand Down

1 comment on commit fbd0688

@vercel
Copy link

@vercel vercel bot commented on fbd0688 Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

anchor-docs – ./

anchor-docs-git-master-200ms.vercel.app
anchor-lang.com
anchor-docs-200ms.vercel.app
www.anchor-lang.com

Please sign in to comment.