Fix potential integer overflow in Balance (#40)
An usize overflow can occur in `Balance::promote_to_ready` when `self.not_ready` has length 0. See my comment here: https://github.com/tower-rs/tower/pull/39#discussion_r163967979 Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This commit is contained in:
parent
777888da7d
commit
251509a200
|
@ -148,6 +148,11 @@ where
|
|||
-> Result<(), Error<<D::Service as Service>::Error, D::DiscoverError>>
|
||||
{
|
||||
let n = self.not_ready.len();
|
||||
if n == 0 {
|
||||
trace!("promoting to ready: not_ready is empty, skipping.");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
debug!("promoting to ready: {}", n);
|
||||
// Iterate through the not-ready endpoints from right to left to prevent removals
|
||||
// from reordering services in a way that could prevent a service from being polled.
|
||||
|
|
Loading…
Reference in New Issue