6631046: BufferedInputStream.available() reports negative int on very large inputstream
Reviewed-by: dholmes, alanb, mduigou
This commit is contained in:
parent
1d73aa8704
commit
a48d403c44
@ -395,7 +395,11 @@ class BufferedInputStream extends FilterInputStream {
|
||||
* or an I/O error occurs.
|
||||
*/
|
||||
public synchronized int available() throws IOException {
|
||||
return getInIfOpen().available() + (count - pos);
|
||||
int n = count - pos;
|
||||
int avail = getInIfOpen().available();
|
||||
return n > (Integer.MAX_VALUE - avail)
|
||||
? Integer.MAX_VALUE
|
||||
: n + avail;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -273,7 +273,11 @@ class PushbackInputStream extends FilterInputStream {
|
||||
*/
|
||||
public int available() throws IOException {
|
||||
ensureOpen();
|
||||
return (buf.length - pos) + super.available();
|
||||
int n = buf.length - pos;
|
||||
int avail = super.available();
|
||||
return n > (Integer.MAX_VALUE - avail)
|
||||
? Integer.MAX_VALUE
|
||||
: n + avail;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user