From df09c1aa63b442d41ddd1b57245da1c62ffca514 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 6 Jun 2013 17:51:43 +0200 Subject: stream: don't adjust stream position if seek succeeds, but read fails This was probably done this way to ensure that after a successful seek, the reported stream position is the same as the requested seek position. But it doesn't make too much sense, since both stream->pos and the stream implementation's internal position will go out of sync. --- stream/stream.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'stream') diff --git a/stream/stream.c b/stream/stream.c index e9a0478609..ddebc6da74 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -570,8 +570,7 @@ static int stream_seek_long(stream_t *s, int64_t pos) } pos -= s->buf_len; } - // Fill failed, but seek still is a success. - s->pos += pos; + // Fill failed, but seek still is a success (partially). s->buf_pos = 0; s->buf_len = 0; s->eof = 0; // eof should be set only on read @@ -615,7 +614,7 @@ int stream_skip(stream_t *s, int64_t len) int r = stream_seek(s, target - 1); if (r) { stream_read_char(s); - return !stream_eof(s); + return !stream_eof(s) && stream_tell(s) == target; } return r; } -- cgit v1.2.3