staticcheck/vrp: short-circuit widening in presence of too many constants
@@ -722,6 +722,11 @@ func (g *Graph) widen(c Constraint, consts []Z) bool {
}
nlc := NInfinity
nuc := PInfinity
+
+ // Don't get stuck widening for an absurd amount of time due
+ // to an excess number of constants, as may be present in
+ // table-based scanners.
+ if len(consts) < 1000 {
for _, co := range consts {
if co.Cmp(ni.Lower) <= 0 {
nlc = co
@@ -734,6 +739,7 @@ func (g *Graph) widen(c Constraint, consts []Z) bool {
break
}
}
+ }
if !oi.IsKnown() {
return ni, true
