[Scummvm-cvs-logs] scummvm master -> 5bfd2f675620f69e23cefbaf8553cb341a9f992c
lordhoto
lordhoto at gmail.com
Mon Jan 28 17:35:58 CET 2013
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5bfd2f6756 COMMON: Fix successive seeks in BufferedSeekableReadStream.
Commit: 5bfd2f675620f69e23cefbaf8553cb341a9f992c
https://github.com/scummvm/scummvm/commit/5bfd2f675620f69e23cefbaf8553cb341a9f992c
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-01-28T08:34:37-08:00
Commit Message:
COMMON: Fix successive seeks in BufferedSeekableReadStream.
This fixes the failing test case added in
da8eeb9dbed2102764b3ca0697d6882bae0402cc.
Thanks to wjp for his input on this.
Changed paths:
common/stream.cpp
diff --git a/common/stream.cpp b/common/stream.cpp
index 57b1b8b..2851b3a 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -393,7 +393,14 @@ bool BufferedSeekableReadStream::seek(int32 offset, int whence) {
// just seek normally in the parent stream.
if (whence == SEEK_CUR)
offset -= (_bufSize - _pos);
- _pos = _bufSize;
+ // We invalidate the buffer here. This assures that successive seeks
+ // do not have the chance to incorrectly think they seeked back into
+ // the buffer.
+ // Note: This does not take full advantage of the buffer. But it is
+ // a simple way to prevent nasty errors. It would be possible to take
+ // full advantage of the buffer by saving its actual start position.
+ // This seems not worth the effort for this seemingly uncommon use.
+ _pos = _bufSize = 0;
_parentStream->seek(offset, whence);
}
More information about the Scummvm-git-logs
mailing list