Added new RemoveRange validation check to see if the resulting range (index + count...
authorAndrew Hoefling <andrew@hoeflingsoftware.com>
Wed, 6 Mar 2019 01:31:19 +0000 (20:31 -0500)
committerSantiago Fernandez Madero <safern@microsoft.com>
Fri, 8 Mar 2019 19:20:58 +0000 (11:20 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/f48e28bbd7e14fe9b6c708fe57624324a5e604eb

src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs

index 1a83b3f..16939e4 100644 (file)
@@ -209,12 +209,17 @@ namespace System.Collections.ObjectModel
 
             if ((uint)index > (uint)items.Count)
             {
-                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert);
+                ThrowHelper.ThrowArgumentOutOfRange_IndexException();
             }
 
             if (count < 0)
             {
-                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_ListInsert);
+                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
+            }
+
+            if ((Int64)index + (Int64)count > items.Count)
+            {
+                ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
             }
 
             int length = items.Count;