Skip to content

Commit

Permalink
address overflow on bitshift in backoff_time
Browse files Browse the repository at this point in the history
Fixes #29.
  • Loading branch information
dam5h authored and hrxi committed Dec 4, 2024
1 parent 99a26ba commit e0b0a9e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,12 @@ impl BackgroundTask {
})
}
fn backoff_time(&self) -> (bool, Duration) {
let backoff_count: u64 = self.backoff_count.into();
let backoff_time = if backoff_count >= 1 {
Duration::from_millis(500 * (1 << (backoff_count - 1)))
let backoff_time = if self.backoff_count >= 1 {
Duration::from_millis(
500u64
.checked_shl(self.backoff_count - 1)
.unwrap_or(u64::MAX),
)
} else {
Duration::from_millis(0)
};
Expand Down

0 comments on commit e0b0a9e

Please sign in to comment.