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:
parent
96086b7733
commit
62d934dd8e
@ -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")
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user