[670974] Use the underlying BaseStream to read bytes instead of trying to peek a...
authorMiguel de Icaza <miguel@gnome.org>
Mon, 14 Feb 2011 14:38:02 +0000 (09:38 -0500)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 14 Feb 2011 14:38:02 +0000 (09:38 -0500)
commitb4e04147765853636ce14ebdb1eb6069975301e9
treee52e1ae4d394ae11d7e67e9334e549ea58602b35
parent95dcd2ad9bf4fe95b5c43b4ff0da2f84a68e4807
[670974] Use the underlying BaseStream to read bytes instead of trying to peek a character.

Peeking a character as it turns out is a really bad idea as it involves the encoder
to pull characters.   If the PeekChar happens to read a byte that is part of a
UTF8 string that needs more characters to process we would end up with the reported
crash.

Atsushi Enomoto tracked this down, and the fix is to use the binaryreader.BaseStream
to directly call into ReadByte and Read without ever probing with PeekChar ().   It
is not really possible to use BinaryReader.ReadByte since this one can throw on
end-of-buffer conditions instead of returning -1
mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryReader.cs