Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=79973 --- shadow/79973 2006-11-19 03:15:49.000000000 -0500 +++ shadow/79973.tmp.4496 2006-11-19 03:15:49.000000000 -0500 @@ -0,0 +1,79 @@ +Bug#: 79973 +Product: Mono: Class Libraries +Version: 1.2 +OS: All +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Minor +Component: CORLIB +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: List<T> argument check is invalid. + +List<T> argument check is invalid. + +void CheckIndex (int index) +{ + if (index < 0 || (uint) index > (uint) _size) + throw new ArgumentOutOfRangeException ("index"); +} + +CheckIndex will pass if index equals to _size, that's not correct. I think +the author try using CheckIndex() in Insert(), so he Changed the +CheckIndex() behavior. + +Sorry my poor English, let's just see my patch: + +=================================================================== +--- class/corlib/System.Collections.Generic/List.cs (revision 68052) ++++ class/corlib/System.Collections.Generic/List.cs (working copy) +@@ -349,13 +349,20 @@ + + void CheckIndex (int index) + { ++ if (index < 0 || (uint) index >= (uint) _size) ++ throw new ArgumentOutOfRangeException +("index"); ++ } ++ ++ void CheckInsertIndex (int index) ++ { + if (index < 0 || (uint) index > (uint) _size) + throw new ArgumentOutOfRangeException +("index"); + } + + public void Insert (int index, T item) + { +- CheckIndex (index); ++ CheckInsertIndex (index); ++ + GrowIfNeeded (1); + Shift (index, 1); + this [index] = item; +@@ -371,7 +378,7 @@ + public void InsertRange (int index, IEnumerable <T> collection) + { + CheckCollection (collection); +- CheckIndex (index); ++ CheckInsertIndex (index); + ICollection <T> c = collection as ICollection <T>; + if (c != null) + InsertCollection (index, c); +@@ -540,8 +547,7 @@ + + public T this [int index] { + get { +- if ((uint) index >= (uint) _size) +- throw new +ArgumentOutOfRangeException ("index"); ++ CheckIndex (index); + return _items [index]; + } + set { _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
