Skip to content

Commit 2795ee9

Browse files
graph: Fix retry_strategy underflow when limit is 0
Use saturating_sub to avoid underflow when limit is set to 0.
1 parent 192869f commit 2795ee9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

graph/src/util/futures.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ pub fn retry_strategy(
412412
Some(limit) => {
413413
// Items are delays *between* attempts,
414414
// so subtract 1 from limit.
415-
Box::new(backoff.take(limit - 1))
415+
// Use saturating_sub to avoid underflow if limit is set to 0
416+
Box::new(backoff.take(limit.saturating_sub(1)))
416417
}
417418
None => Box::new(backoff),
418419
}

0 commit comments

Comments
 (0)