[mono/mono] [2 commits] 6c3e614c: Fix off-by-one error in ArraySegment
| Newsgroups | gmane.comp.gnome.mono.patches |
|---|---|
| Message-ID | <0000014276ad2fab-3959a1f7-2b4f-4b1d-aa35-eaee7630d301-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/748a705230db...658753c9c8c2
Commit: 6c3e614cc5bf817b6e6451121883c83c1401a81e
Author: Leonardo Taglialegne <[email protected]> (miniBill)
Date: 2013-11-05 19:49:21 GMT
URL: https://github.com/mono/mono/commit/6c3e614cc5bf817b6e6451121883c83c1401a81e
Fix off-by-one error in ArraySegment
Changed paths:
M mcs/class/corlib/System/ArraySegment.cs
M mcs/class/corlib/Test/System/ArraySegmentTest.cs
Modified: mcs/class/corlib/System/ArraySegment.cs
===================================================================
@@ -134,13 +134,13 @@ public override int GetHashCode ()
T IList<T>.this[int index] {
get {
- if (index < 0 || count < index)
+ if (index < 0 || index >= count)
throw new ArgumentOutOfRangeException ("index");
return array[offset + index];
}
set {
- if (index < 0 || count < index)
+ if (index < 0 || index >= count)
throw new ArgumentOutOfRangeException ("index");
array[offset + index] = value;
Modified: mcs/class/corlib/Test/System/ArraySegmentTest.cs
===================================================================
@@ -260,6 +260,24 @@ public void IList_Indexer ()
s[1] = -3;
Assert.AreEqual (-3, s[1], "#2a");
}
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void IList_IndexerErrorTest1 ()
+ {
+ byte[] arr = new byte[4];
+ IList<byte> seg = new ArraySegment<byte> (arr, 1, 2);
+ seg[-1] = 3;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void IList_IndexerErrorTest2 ()
+ {
+ byte[] arr = new byte[4];
+ IList<byte> seg = new ArraySegment<byte> (arr);
+ seg[4] = 3;
+ }
#endif
}
}
Commit: 658753c9c8c2b54753d4949d368703d0b2c3a00a
Author: Miguel de Icaza <[email protected]> (migueldeicaza)
Date: 2013-11-20 18:00:03 GMT
URL: https://github.com/mono/mono/commit/658753c9c8c2b54753d4949d368703d0b2c3a00a
Merge pull request #780 from miniBill/master
Fix off-by-one error in ArraySegment
Changed paths:
M mcs/class/corlib/System/ArraySegment.cs
M mcs/class/corlib/Test/System/ArraySegmentTest.cs
Modified: mcs/class/corlib/System/ArraySegment.cs
===================================================================
@@ -134,13 +134,13 @@ public override int GetHashCode ()
T IList<T>.this[int index] {
get {
- if (index < 0 || count < index)
+ if (index < 0 || index >= count)
throw new ArgumentOutOfRangeException ("index");
return array[offset + index];
}
set {
- if (index < 0 || count < index)
+ if (index < 0 || index >= count)
throw new ArgumentOutOfRangeException ("index");
array[offset + index] = value;
Modified: mcs/class/corlib/Test/System/ArraySegmentTest.cs
===================================================================
@@ -260,6 +260,24 @@ public void IList_Indexer ()
s[1] = -3;
Assert.AreEqual (-3, s[1], "#2a");
}
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void IList_IndexerErrorTest1 ()
+ {
+ byte[] arr = new byte[4];
+ IList<byte> seg = new ArraySegment<byte> (arr, 1, 2);
+ seg[-1] = 3;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void IList_IndexerErrorTest2 ()
+ {
+ byte[] arr = new byte[4];
+ IList<byte> seg = new ArraySegment<byte> (arr);
+ seg[4] = 3;
+ }
#endif
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches