FV-ANC-1-CL2 Division by zero
Bad
// Risk of crashing if divisor is zero
let avg = total / count;
Good
// Explicitly check for zero divisor before division
if count == 0 {
return Err(ProgramError::InvalidArgument);
}
let avg = total / count;
Last updated
Was this helpful?