Patch from Juraj:
authorMiguel de Icaza <miguel@gnome.org>
Wed, 31 Oct 2007 04:10:33 +0000 (04:10 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 31 Oct 2007 04:10:33 +0000 (04:10 -0000)
2007-10-10  Juraj Skripsky <js@hotfeet.ch>

* Dictionary.cs (Enumerator.MoveNext): Handle the case where we
had already reached the end. Fixes bug #332534.

svn path=/trunk/mcs/; revision=88534

mcs/class/corlib/System.Collections.Generic/ChangeLog
mcs/class/corlib/System.Collections.Generic/Dictionary.cs
mcs/class/corlib/Test/System.Collections.Generic/DictionaryTest.cs

index cafbbf6c515993ab432018b824ea972e343fac9c..1c701a37ed87219f1c0c22aad321b9e2589b7c0c 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-10  Juraj Skripsky <js@hotfeet.ch>
+
+       * Dictionary.cs (Enumerator.MoveNext): Handle the case where we
+       had already reached the end. Fixes bug #332534.
+
 2007-08-20  Jb Evain  <jbevain@novell.com>
 
        * List.cs (AddCollection): return early if the collection
index 322cd30cf8fcf16ad3855b0ca0c8faad466dded3..c96ec149e365cc9039d6ba57f4b87a55ca227d0d 100644 (file)
@@ -761,7 +761,7 @@ namespace System.Collections.Generic {
                                do {
                                        if (cur == NO_SLOT) {
                                                //move to next item in table, check if we reached the end
-                                               if (++curTableItem == dictionary.table.Length)
+                                               if (++curTableItem >= dictionary.table.Length)
                                                        return false;
 
                                                cur = dictionary.table [curTableItem] - 1;
index 95f034bb5b9fb01b29219eccd6b305fd9dbb9fdf..270f840b1bed11222cd6b8968c1eceb1d88254c1 100644 (file)
@@ -691,6 +691,20 @@ namespace MonoTests.System.Collections.Generic {
                        Assert.IsNull(d[2]);
                        Assert.IsNull(d["foo"]);
                }
+
+               // Bug: #332534
+               [Test]
+               public void Dictionary_MoveNext ()
+               {
+                       Dictionary<int,int> a = new Dictionary<int,int>();
+                       a.Add(3,1);
+                       a.Add(4,1);
+
+                       IEnumerator en = a.GetEnumerator();
+                       for (int i = 1; i < 10; i++)
+                               en.MoveNext();
+               }
+               
        }
 }