[9] RFR 8163518: Integer overflow in StringBufferInputStream.read(byte[], int, int) and CharArrayReader.read(char[], int, int)
Roger Riggs
Roger.Riggs at Oracle.com
Wed Aug 10 19:52:42 UTC 2016
Hi,
It might be simpler to use:
k = Math.max(n, 0); // non-negative or zero
k = Math.min(k, count - pos); // the smaller of the request and
what's available
(or combine in a single expression)
Roger
On 8/10/2016 3:40 PM, Aleksey Shipilev wrote:
> On 08/10/2016 08:55 PM, Ivan Gerasimov wrote:
>> http://cr.openjdk.java.net/~igerasim/8163518/01/webrev/
>>
>> Would you please help review it once again?
> I wonder, shouldn't it be (n <= k) here:
>
> 164 long k = count - pos;
> 165 if (n < k) {
> 166 k = (n <= 0) ? 0 : n;
> 167 }
> 168 pos += k;
> 169 return k;
>
> "k" is the max number of chars to skip. It should be possible to skip
> all remaining chars when (n == k), right?
>
> Thanks,
> -Aleksey
>
>
>
More information about the core-libs-dev
mailing list