From 3cdb557455e13549eb61f18512a8a61b7fd5fb0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Wed, 17 Sep 2025 20:26:45 +0200 Subject: [PATCH] Use saturating add --- src/api/core/two_factor/email.rs | 2 +- src/api/core/two_factor/protected_actions.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/core/two_factor/email.rs b/src/api/core/two_factor/email.rs index 460caa7b..63e4508b 100644 --- a/src/api/core/two_factor/email.rs +++ b/src/api/core/two_factor/email.rs @@ -286,7 +286,7 @@ impl EmailTokenData { } pub fn add_attempt(&mut self) { - self.attempts += 1; + self.attempts = self.attempts.saturating_add(1); } pub fn to_json(&self) -> String { diff --git a/src/api/core/two_factor/protected_actions.rs b/src/api/core/two_factor/protected_actions.rs index 04ab08f5..04c273ef 100644 --- a/src/api/core/two_factor/protected_actions.rs +++ b/src/api/core/two_factor/protected_actions.rs @@ -51,7 +51,7 @@ impl ProtectedActionData { } pub fn add_attempt(&mut self) { - self.attempts += 1; + self.attempts = self.attempts.saturating_add(1); } pub fn time_since_sent(&self) -> TimeDelta {