[fpc-devel] Read from memory stream with position before start of file

C Western l at c-m-w.me.uk
Thu Jan 1 15:47:03 CET 2009

While finding the bug #12897 I found that a memory stream position could
be set to before the start of the file without giving an error, and
subsequent reads would appear to work (unless the position was so far
off an invalid region of memory was read). I found the precise problem
by patching TCustomMemoryStream to raise an exception if the position is
set before the start of the file. Should an exception be raised in this
circumstance, which would make finding bugs easier? Or should the
position just be set to 0, which would be more consistent with the
behaviour when going beyond the end of the stream?

See attached patch for the sort of thing I am thinking of.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stream.patch
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20090101/77b57530/attachment.ksh>

More information about the fpc-devel mailing list