mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 21:08:34 +00:00
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:
parent
4508aa7c35
commit
9c196bd2d5
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user