1
0
Эх сурвалжийг харах

Adding overflow check to Range.

Bart De Smet 8 жил өмнө
parent
commit
106df57bb5

+ 4 - 0
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs

@@ -16,6 +16,10 @@ namespace System.Linq
             if (count < 0)
                 throw new ArgumentOutOfRangeException(nameof(count));
 
+            var end = (long)start + count - 1L;
+            if (count < 0 || end > int.MaxValue)
+                throw new ArgumentOutOfRangeException(nameof(count));
+
             if (count == 0)
                 return Empty<int>();