[Mono-bugs] [Bug 79973][Min] New - List<T> argument check is invalid.
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sun Nov 19 03:15:51 EST 2006
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 redforks at gmail.com.
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: mono-bugs at ximian.com
+ReportedBy: redforks at gmail.com
+QAContact: mono-bugs at ximian.com
+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 {
More information about the mono-bugs
mailing list