Fix issue where an empty file could be read forever.

If you gave the class an empty file, it would get back -1 for read(),
causing it to fall forever into negative values, never escaping the
existing conditions.

The side effect of this was weird corner cases where these infinite
reads could clog up threads, causing audio recordings to get blocked
and such.

Fixes #8898
This commit is contained in:
Greyson Parrelli 2019-07-01 16:31:40 -04:00
parent 4508aa7c35
commit 9c196bd2d5

View File

@ -75,7 +75,8 @@ public class ModernDecryptingPartInputStream {
for (;;) { for (;;) {
int read = in.read(buffer, offset, buffer.length-offset); int read = in.read(buffer, offset, buffer.length-offset);
if (read + offset < buffer.length) offset += read; if (read == -1) throw new IOException("Prematurely reached end of stream!");
else if (read + offset < buffer.length) offset += read;
else return; else return;
} }
} }