Bug 15574. XML deserialization recursion: add array type to known_types?
authorbrendanzagaeski <brendan.zagaeski@xamarin.com>
Wed, 27 Nov 2013 03:47:48 +0000 (22:47 -0500)
committerbrendanzagaeski <brendan.zagaeski@xamarin.com>
Wed, 27 Nov 2013 03:47:48 +0000 (22:47 -0500)
One way to prevent https://bugzilla.xamarin.com/show_bug.cgi?id=15574 is to add the problematic array type to the `known_types`.

On the other hand, this might not be the intended use of `known_types`. In that case, perhaps a better fix would be to guard against recursion in the `foreach` loop:

if (t != type)
RegisterTypeAsKnown (t);

mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs

index f3c707e1e77842557bd32261c8414e46e788b528..8e713d78eb17b74b356b275963efe1fce6d35c9c 100755 (executable)
@@ -248,8 +248,10 @@ namespace System.Runtime.Serialization
                                return;
 
                        Type elementType = type;
-                       if (type.HasElementType)
+                       if (type.HasElementType) {
+                               known_types.Add (type);
                                elementType = type.GetElementType ();
+                       }
 
                        known_types.Add (elementType);