Skip to content

Commit

Permalink
StreamHandle: fix subtle bugs during backwards seeking
Browse files Browse the repository at this point in the history
  • Loading branch information
melissalinkert committed Jan 11, 2018
1 parent f5e4cac commit 518f31b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/loci/common/StreamHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,18 @@ public void seek(long pos) throws IOException {
fp = pos;

if (diff < 0) {
// resetStream sets the fp to 0
resetStream();
diff = fp;
diff = pos;
fp = pos;
}
int skipped = stream.skipBytes((int) diff);
while (skipped < diff) {
int n = stream.skipBytes((int) (diff - skipped));
if (n == 0) break;
skipped += n;
}
markManager();
}

/* @see IRandomAccess.write(ByteBuffer) */
Expand Down

0 comments on commit 518f31b

Please sign in to comment.