fix: integer overflow in ports iteration

This commit is contained in:
wwqgtxx 2025-02-28 15:48:25 +08:00
parent 136d114196
commit 05e8f13a8d

View file

@ -139,10 +139,13 @@ func (ranges IntRanges[T]) Range(f func(t T) bool) {
}
for _, r := range ranges {
for i := r.Start(); i <= r.End(); i++ {
for i := r.Start(); i <= r.End() && i >= r.Start(); i++ {
if !f(i) {
return
}
if i+1 < i { // integer overflow
break
}
}
}
}