Skip to content

Commit 2b61482

Browse files
sjuddglide-copybara-robot
authored andcommittedDec 28, 2020
Reset mark position after skipping past the mark limit. Any later reset will throw instead of leaving the stream in a bad/undefined state.
Previously, this would cause us to lose track of the bytes that were skipped. For PNGs, ExifInterface skips past the entire data block, which for some files can exceed the buffer limit. We would return back to the buffer location, decode the image partially and then try to load more from the wrapped stream - which would lead to a quick EOF This is similar to what fillbuf does when we push past the mark limit. PiperOrigin-RevId: 349315836
1 parent 11530fd commit 2b61482

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎library/src/main/java/com/bumptech/glide/load/resource/bitmap/RecyclableBufferedInputStream.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,14 @@ public synchronized long skip(long byteCount) throws IOException {
393393
pos = count;
394394
return read;
395395
}
396-
return read + localIn.skip(byteCount - read);
396+
397+
// We can't skip over the remaining bytes without exceeding the mark limit so there will be no
398+
// way to reset to a proper position in the stream.
399+
long skipped = localIn.skip(byteCount - read);
400+
if (skipped > 0) {
401+
markpos = -1;
402+
}
403+
return read + skipped;
397404
}
398405

399406
/**

0 commit comments

Comments
 (0)
Please sign in to comment.