Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/class
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2010-06-17 03:39:38 +0400
committerMiguel de Icaza <miguel@gnome.org>2010-06-17 03:39:38 +0400
commit449525c8a13b3329a78178818640040c5860cff1 (patch)
tree240ef51fdc3361741b2c5bbe79ef2d047b678363 /mcs/class
parent150a9e53630d5d7b563fe77aeb0657e8c374f4c3 (diff)
Backport fix for 605797
svn path=/branches/mono-2-6/mcs/; revision=159043
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/corlib/System/Random.cs9
1 files changed, 8 insertions, 1 deletions
diff --git a/mcs/class/corlib/System/Random.cs b/mcs/class/corlib/System/Random.cs
index d8c85baef66..10b3554bdb5 100644
--- a/mcs/class/corlib/System/Random.cs
+++ b/mcs/class/corlib/System/Random.cs
@@ -59,7 +59,14 @@ namespace System
int mj, mk;
// Numerical Recipes in C online @ http://www.library.cornell.edu/nr/bookcpdf/c7-1.pdf
- mj = MSEED - Math.Abs (Seed);
+
+ // Math.Abs throws on Int32.MinValue, so we need to work around that case.
+ // Fixes: 605797
+ if (Seed == Int32.MinValue)
+ mj = MSEED - Math.Abs (Int32.MinValue + 1);
+ else
+ mj = MSEED - Math.Abs (Seed);
+
SeedArray [55] = mj;
mk = 1;
for (int i = 1; i < 55; i++) { // [1, 55] is special (Knuth)