From: Jb Evain Date: Tue, 25 Jan 2011 22:47:58 +0000 (+0100) Subject: [linq] Fix overflow check for Count X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=bce773948643a7c68a3cc46da69a6d18cead2064;p=mono.git [linq] Fix overflow check for Count --- diff --git a/mcs/class/System.Core/System.Linq/Enumerable.cs b/mcs/class/System.Core/System.Linq/Enumerable.cs index 56d52d4f453..362099dc97d 100644 --- a/mcs/class/System.Core/System.Linq/Enumerable.cs +++ b/mcs/class/System.Core/System.Linq/Enumerable.cs @@ -637,7 +637,7 @@ namespace System.Linq int counter = 0; using (var enumerator = source.GetEnumerator ()) while (enumerator.MoveNext ()) - counter++; + checked { counter++; } return counter; } @@ -649,7 +649,7 @@ namespace System.Linq int counter = 0; foreach (var element in source) if (predicate (element)) - counter++; + checked { counter++; } return counter; }