[Mono-bugs] [Bug 51741][Nor] New - System.IO.BinaryReader.PeekChar( ) modifies the underlying stream

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 16 Mar 2004 14:56:16 -0500 (EST)


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 gonzalo@ximian.com.

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

--- shadow/51741	2004-03-16 14:56:16.000000000 -0500
+++ shadow/51741.tmp.22715	2004-03-16 14:56:16.000000000 -0500
@@ -0,0 +1,67 @@
+Bug#: 51741
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Red Hat 8.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: CORLIB
+AssignedTo: gonzalo@ximian.com                            
+ReportedBy: dev@6wardlaw.freeserve.co.uk               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.IO.BinaryReader.PeekChar( ) modifies the underlying stream
+
+Description of Problem:
+
+PeekChar( ) on System.IO.BinaryReader modifies the underlying stream.
+
+Essentially, PeekChar( ) calls ReadChar( ) on the underlying stream but 
+doesn't reposition the stream before returning. The 'peeked' char is 
+placed into a buffer which is used for any subsequent ReadChar( ) call.
+
+This causes two problems.
+
+The first is that the underlying stream is not in the same state as it 
+was before the call.
+
+The second is that if the position of the stream is changed after a call 
+to PeekChar( ) a call to ReadChar( ) will return the invalid data from 
+the PeekChar( ) call.
+
+Steps to reproduce the problem:
+
+Create a test application which uses a BinaryReader and also manipulates 
+the underlying stream. ( attached )
+
+How often does this happen? 
+
+Everytime.
+
+Additional Information:
+
+The Microsoft .net implementation of this method does not modify the 
+underlying stream. If the underlying stream is not seekable then PeekChar
+( ) return -1.
+
+------- Additional Comments From dev@6wardlaw.freeserve.co.uk  2003-12-04 17:12 -------
+Created an attachment (id=6113)
+Test case class
+
+
+------- Additional Comments From dev@6wardlaw.freeserve.co.uk  2003-12-04 17:13 -------
+Created an attachment (id=6114)
+Proposed Solution
+
+
+------- Additional Comments From gonzalo@ximian.com  2003-12-04 17:31 -------
+Created an attachment (id=6115)
+The proposed fix in diff -u format
+
+
+------- Additional Comments From gonzalo@ximian.com  2004-03-16 14:56 -------
+I will apply it after mono 0.31 is out.