R7 build broken for Byte Arrays

Apr 19, 2010 at 5:22 PM

Looks like some buffer corruption issue with the latest R7 build when a BYTE property is zero length.  JsonTextReader.ReadAsBytes() seems to exhibit some sort of corruption.

The below sample code shows up the issue (happy to fix if JamesNK can give us a heads-up).

class Program
{
        private class MyClass
        {
            public byte[] Prop1 { get; set; }

            public MyClass()
            {
                Prop1 = new byte[0];
            }
        }
        static void Main(string[] args)
        {
            MyClass[] m = new MyClass[2];
            m[0] = new MyClass();
            m[1] = new MyClass();
            JsonSerializer serializer1 = new JsonSerializer();

            serializer1.Converters.Add(new IsoDateTimeConverter());
            serializer1.NullValueHandling = NullValueHandling.Ignore;
            
            StringWriter writer = new StringWriter();
            serializer1.Serialize(writer, m);
            JsonTextReader jread = new JsonTextReader(new StringReader(writer.GetStringBuilder().ToString()));
            MyClass[] z = (MyClass[])serializer1.Deserialize(jread, typeof(MyClass[]));
	}
}

 

 

Coordinator
Apr 20, 2010 at 9:16 AM

Fixed.