stream: fix overflow in StreamMap::size_hint (#8216)

This commit is contained in:
Minh Vu
2026-06-23 09:49:54 +02:00
committed by GitHub
parent dc3a883b99
commit f59aae423e
2 changed files with 27 additions and 3 deletions
+3 -3
View File
@@ -685,15 +685,15 @@ where
}
fn size_hint(&self) -> (usize, Option<usize>) {
let mut ret = (0, Some(0));
let mut ret: (usize, Option<usize>) = (0, Some(0));
for (_, stream) in &self.entries {
let hint = stream.size_hint();
ret.0 += hint.0;
ret.0 = ret.0.saturating_add(hint.0);
match (ret.1, hint.1) {
(Some(a), Some(b)) => ret.1 = Some(a + b),
(Some(a), Some(b)) => ret.1 = a.checked_add(b),
(Some(_), None) => ret.1 = None,
_ => {}
}