FV-ANC-1-CL1 Overflow/underflow in arithmetic operations
Bad
// Adding two values without handling overflow
let balance = ctx.accounts.user.balance + amount;
Good
// Using `checked_add` to safely handle overflow
let balance = ctx.accounts.user.balance.checked_add(amount).ok_or(ProgramError::InvalidArgument)?;
Last updated
Was this helpful?