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
diff options
context:
space:
mode:
authorRodrigo Kumpera <kumpera@gmail.com>2013-06-11 23:55:48 +0400
committerRodrigo Kumpera <kumpera@gmail.com>2013-06-11 23:55:48 +0400
commit043b9d20258f7100df8ed1e96d355fd98e12fb51 (patch)
tree601a051fe541a09fee03d0d64fb90b0878ae51a6 /mcs/class/System.Numerics
parentc9b90f8f5b9c9925208b2a77594a32985e0ed1c0 (diff)
Fix new BigInteger().GetHashCode() to not throw.
Diffstat (limited to 'mcs/class/System.Numerics')
-rw-r--r--mcs/class/System.Numerics/System.Numerics/BigInteger.cs3
-rw-r--r--mcs/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs2
2 files changed, 4 insertions, 1 deletions
diff --git a/mcs/class/System.Numerics/System.Numerics/BigInteger.cs b/mcs/class/System.Numerics/System.Numerics/BigInteger.cs
index 4ae2ed47ca7..1a32f7eceae 100644
--- a/mcs/class/System.Numerics/System.Numerics/BigInteger.cs
+++ b/mcs/class/System.Numerics/System.Numerics/BigInteger.cs
@@ -1834,8 +1834,9 @@ namespace System.Numerics {
public override int GetHashCode ()
{
uint hash = (uint)(sign * 0x01010101u);
+ int len = data != null ? data.Length : 0;
- for (int i = 0; i < data.Length; ++i)
+ for (int i = 0; i < len; ++i)
hash ^= data [i];
return (int)hash;
}
diff --git a/mcs/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs b/mcs/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs
index a8e537e90a1..dd5afb61204 100644
--- a/mcs/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs
+++ b/mcs/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs
@@ -1139,6 +1139,8 @@ namespace MonoTests.System.Numerics
a = new BigInteger ();
Assert.AreEqual (a, BigInteger.GreatestCommonDivisor (a, a), "#14");
+ a = new BigInteger ();
+ Assert.AreEqual (BigInteger.Zero.GetHashCode (), a.GetHashCode (), "#15");
}
}
}