From: Ben Adams Date: Sun, 26 Feb 2017 00:02:14 +0000 (+0000) Subject: Better ArraySegment .ctor tests (#9800) X-Git-Tag: accepted/tizen/base/20180629.140029~2111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43647666150a40fd78caf1c58b2cc62e322f1e21;p=platform%2Fupstream%2Fcoreclr.git Better ArraySegment .ctor tests (#9800) --- diff --git a/src/mscorlib/src/System/ArraySegment.cs b/src/mscorlib/src/System/ArraySegment.cs index 98e0b79..fa02938 100644 --- a/src/mscorlib/src/System/ArraySegment.cs +++ b/src/mscorlib/src/System/ArraySegment.cs @@ -45,8 +45,9 @@ namespace System public ArraySegment(T[] array, int offset, int count) { // Validate arguments, check is minimal instructions with reduced branching for inlinable fast-path + // Negative values discovered though conversion to high values when converted to unsigned // Failure should be rare and location determination and message is delegated to failure functions - if (array == null || (offset | count) < 0 || (array.Length - offset < count)) + if (array == null || (uint)offset > (uint)array.Length || (uint)count > (uint)(array.Length - offset)) ThrowHelper.ThrowArraySegmentCtorValidationFailedExceptions(array, offset, count); Contract.EndContractBlock();