mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-05-01 00:00:02 -04:00
TMI-119: Fixed endless loop, trying to read 0 bytes at EOF caused by bogus segment lengths...
This commit is contained in:
+2
-1
@@ -271,7 +271,8 @@ final class JPEGSegmentImageInputStream extends ImageInputStreamImpl {
|
||||
while (total < len) {
|
||||
repositionAsNecessary();
|
||||
|
||||
int count = stream.read(b, off + total, (int) Math.min(len - total, segment.end() - streamPos));
|
||||
long bytesLeft = segment.end() - streamPos; // If no more bytes after reposition, we're at EOF
|
||||
int count = bytesLeft == 0 ? -1 : stream.read(b, off + total, (int) Math.min(len - total, bytesLeft));
|
||||
|
||||
if (count == -1) {
|
||||
// EOF
|
||||
|
||||
Reference in New Issue
Block a user