2007-11-02 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 2 Nov 2007 09:37:12 +0000 (09:37 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 2 Nov 2007 09:37:12 +0000 (09:37 -0000)
* StreamReader.cs : Encoding.GetMaxCharCount() does not always return
  the maximum max char count for Decoder.GetChars() since it might
  contain pending buffer by flush. Fixed bug #338370.

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

mcs/class/corlib/System.IO/ChangeLog
mcs/class/corlib/System.IO/StreamReader.cs

index 0f74f692d37e2f0a9e2b9f35c56573696790cd42..42bbb1ad7b5dcaeeefa1d1c5a8f808c32b4d7432 100644 (file)
@@ -1,3 +1,9 @@
+2007-11-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * StreamReader.cs : Encoding.GetMaxCharCount() does not always return
+         the maximum max char count for Decoder.GetChars() since it might
+         contain pending buffer by flush. Fixed bug #338370.
+
 2007-11-01  Miguel de Icaza  <miguel@novell.com>
 
        * Path.cs (GetDirectoryName): The paths returned from this routine
index 0d1f0a415f557b1fd5c93bbf9605e773b4697375..70e08f91967a70e2ed9f1fb55ce8af40e325f97d 100644 (file)
@@ -192,7 +192,10 @@ namespace System.IO {
                        do_checks = detect_encoding_from_bytemarks ? 1 : 0;
                        do_checks += (preamble.Length == 0) ? 0 : 2;
                        
-                       decoded_buffer = new char [encoding.GetMaxCharCount (buffer_size)];
+                       // since GetChars() might add flushed character, it 
+                       // should have additional char buffer for extra 1 
+                       // (probably 1 is ok, but might be insufficient. I'm not sure)
+                       decoded_buffer = new char [encoding.GetMaxCharCount (buffer_size) + 1];
                        decoded_count = 0;
                        pos = 0;
                }