< prev index next >
src/java.base/share/classes/java/io/CharArrayReader.java
Print this page
rev 15329 : imported patch 8163518-Integer-overflow-in-StringBufferInputStream-read-byte-int-int
*** 129,140 ****
}
if (pos >= count) {
return -1;
}
! if (pos + len > count) {
! len = count - pos;
}
if (len <= 0) {
return 0;
}
System.arraycopy(buf, pos, b, off, len);
--- 129,142 ----
}
if (pos >= count) {
return -1;
}
!
! int avail = count - pos;
! if (len > avail) {
! len = avail;
}
if (len <= 0) {
return 0;
}
System.arraycopy(buf, pos, b, off, len);
*** 156,173 ****
* @exception IOException If the stream is closed, or an I/O error occurs
*/
public long skip(long n) throws IOException {
synchronized (lock) {
ensureOpen();
! if (pos + n > count) {
! n = count - pos;
! }
! if (n < 0) {
! return 0;
}
! pos += n;
! return n;
}
}
/**
* Tells whether this stream is ready to be read. Character-array readers
--- 158,174 ----
* @exception IOException If the stream is closed, or an I/O error occurs
*/
public long skip(long n) throws IOException {
synchronized (lock) {
ensureOpen();
!
! long k = count - pos;
! if (n < k) {
! k = (n <= 0) ? 0 : n;
}
! pos += k;
! return k;
}
}
/**
* Tells whether this stream is ready to be read. Character-array readers
< prev index next >