From e9de202a860a669e31acbc57c9f677216b466d0b Mon Sep 17 00:00:00 2001 From: Andrew Hoefling Date: Tue, 5 Mar 2019 20:31:19 -0500 Subject: [PATCH] Added new RemoveRange validation check to see if the resulting range (index + count) > items.Count and if it is true throw ArgumentException Commit migrated from https://github.com/dotnet/coreclr/commit/f48e28bbd7e14fe9b6c708fe57624324a5e604eb --- .../src/System/Collections/ObjectModel/Collection.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs index 1a83b3f..16939e4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs @@ -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; -- 2.7.4