1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-17 06:10:51 +01:00

fix integer overflows

* available() method in ChunkFileInputStream.java
* free "ahead space" calculation in CircularFileWriter.java
This commit is contained in:
kapodamy 2020-04-01 15:11:57 -03:00
parent 96086b7733
commit 62d934dd8e
2 changed files with 2 additions and 2 deletions

View File

@ -104,7 +104,7 @@ public class ChunkFileInputStream extends SharpStream {
@Override @Override
public long available() { public long available() {
return (int) (length - position); return length - position;
} }
@SuppressWarnings("EmptyCatchBlock") @SuppressWarnings("EmptyCatchBlock")

View File

@ -221,7 +221,7 @@ public class CircularFileWriter extends SharpStream {
available = out.length - offsetOut; available = out.length - offsetOut;
} }
int length = Math.min(len, (int) available); int length = Math.min(len, (int) Math.min(Integer.MAX_VALUE, available));
out.write(b, off, length); out.write(b, off, length);
len -= length; len -= length;