[Mono-bugs] [Bug 76489][Wis] New - Binaryreader.GetChars(0) always fails

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Oct 20 06:26:29 EDT 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ck at carlo-kok.com.

http://bugzilla.ximian.com/show_bug.cgi?id=76489

--- shadow/76489	2005-10-20 06:26:29.000000000 -0400
+++ shadow/76489.tmp.12114	2005-10-20 06:26:29.000000000 -0400
@@ -0,0 +1,62 @@
+Bug#: 76489
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: ck at carlo-kok.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Binaryreader.GetChars(0) always fails
+
+Description of problem:
+Reading 0 chars from a BinaryReader fails: (works on MS.net)
+
+--- testcase: ---
+using System;
+using System.IO;
+
+namespace A {
+class Test {
+public static void Main() {
+
+MemoryStream ms = new MemoryStream(); ms.WriteByte(0); ms.WriteByte(0);
+ms.Position = 0;
+BinaryReader rs = new BinaryReader(ms);
+rs.ReadChars(0);
+}
+}
+}
+
+
+--- Result: ---
+Unhandled Exception: System.IO.EndOfStreamException: Failed to read past
+end of stream.
+in <0x000df> System.IO.BinaryReader:ReadChars (Int32 count)
+in <0x00065> A.Test:Main ()
+
+--- Expected Result: ---
+[nothing]
+
+--- Cause: --
+BinaryReader.cs
+
+		public virtual char[] ReadChars(int count) {
+			if (count < 0) {
+				throw new ArgumentOutOfRangeException("count is less than 0");
+			}
+
+			char[] full = new char[count];
+			int chars = Read(full, 0, count);
+			
+			if (chars == 0) {
+				throw new EndOfStreamException();
+
+chars will always be 0 because nothing is supposed to be read.


More information about the mono-bugs mailing list