Author: zoltan
Date: 2007-08-24 17:35:38 -0400 (Fri, 24 Aug 2007)
New Revision: 84826
Modified:
trunk/mcs/class/corlib/System.Collections/ArrayList.cs
trunk/mcs/class/corlib/System.Collections/ChangeLog
Log:
2007-08-25 Zoltan Varga <[EMAIL PROTECTED]>
* ArrayList.cs: Fix overflows in BinarySearch and qsort.
Modified: trunk/mcs/class/corlib/System.Collections/ArrayList.cs
===================================================================
--- trunk/mcs/class/corlib/System.Collections/ArrayList.cs 2007-08-24
21:33:40 UTC (rev 84825)
+++ trunk/mcs/class/corlib/System.Collections/ArrayList.cs 2007-08-24
21:35:38 UTC (rev 84826)
@@ -622,7 +622,8 @@
while (x <= y)
{
- z = (x + y) / 2;
+ // Be careful with overflows
+ z = x + ((y - x) / 2);
r = comparer.Compare(value,
m_Adaptee[z]);
@@ -716,7 +717,8 @@
// Pick the pivot using the median-of-three
strategy.
- middle = (left + right) / 2;
+ // Be careful with overflows
+ middle = left + ((right - left) / 2);
if (comparer.Compare(list[middle], list[left])
< 0)
{
Modified: trunk/mcs/class/corlib/System.Collections/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Collections/ChangeLog 2007-08-24 21:33:40 UTC
(rev 84825)
+++ trunk/mcs/class/corlib/System.Collections/ChangeLog 2007-08-24 21:35:38 UTC
(rev 84826)
@@ -1,3 +1,7 @@
+2007-08-25 Zoltan Varga <[EMAIL PROTECTED]>
+
+ * ArrayList.cs: Fix overflows in BinarySearch and qsort.
+
2007-08-08 Atsushi Enomoto <[EMAIL PROTECTED]>
* ReadOnlyCollectionBase.cs CollectionBase.cs :
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches