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
fork-5.53.8
Greyson Parrelli 2019-07-01 16:31:40 -04:00
rodzic 4508aa7c35
commit 9c196bd2d5
1 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

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