[Scummvm-devel] The semantics of reading beyond the end of a stream

Norbert Lange lange at chello.at
Sun Sep 13 13:54:50 CEST 2009


read the posts regarding "incorrect use of stream functions" on this list.

Code that depends on a fixed value in case of EOS needs to be fixed (and  
found first), the reason why readByte is not behaving in the described way  
is that scummvm would fail loading the theme until "someone" fixes the  
xmlparser class.
Further I assumed that such illbehaving code would read characters, so the  
16 and 32 bit reads dint get this temporary workaround as I dint expect  
them to cause trouble.

Norbert

Am 13.09.2009, 12:49 Uhr, schrieb Torbjörn Andersson  
<eriktorbjorn at telia.com>:

> Hi,
>
> I was just wondering... until recently, reading an 8-, 16- or 32-bit
> value completely beyond the end of a stream would return 0. This is
> because the readByte()/readSByte() functions do, and the other functions
> were implemented by calling readByte().
>
> With the recent (r44027) changes this. The 16- and 32-bit functions are
> implemented in terms of read(), so reading beyond the end of the stream
> is undefined. The readByte() function still returns 0, but there's a
> FIXME comment about removing this.
>
> The change uncovered a crash in The 7th Guest, which is how I noticed it
> in the first place. (I can't believe I've spent this much time hunting
> for a bug in a game I don't even particularly like! :-)
>
> What is the desired behaviour here? It seems a bit inconsistent that the
> functions behave differently. In my opinion, either all of them should
> return 0 or none of them should.
>
> Torbjörn Andersson
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008  
> 30-Day
> trial. Simplify your report design, integration and deployment - and  
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Scummvm-devel mailing list
> Scummvm-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scummvm-devel





More information about the Scummvm-devel mailing list