8219597: (bf) Heap buffer state changes could provoke unexpected exceptions

Brian Burkhalter brian.burkhalter at oracle.com
Fri Mar 1 17:28:38 UTC 2019


> On Mar 1, 2019, at 2:25 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> 
> On 27/02/2019 19:36, Brian Burkhalter wrote:
>> This issue [1] was instigated by this comment [2]. The change [3] hopefully reduces the exposure of heap buffers to changes in the buffer state, notably the position (cursor).
>> 
> I saw Roger's mail but I think these changes just mean the position/limit checked in the preconditions are the values used.  So I think the changes are okay. One more to look at is the checkIndex usages in the new 2-arg slice method. 

Yes I think that this
 117     public $Type$Buffer slice(int index, int length) {
 118         Objects.checkIndex(index, limit() + 1);
 119         Objects.checkIndex(length, limit() - index + 1);
should be changed to
 117     public $Type$Buffer slice(int index, int length) {
 118         Objects.checkFromIndexSize(index, length, limit() + 1);
and also in the other places slice(int,int) occurs. IIRC I had it that way to begin with and modified it while addressing comments. I think however that this change perhaps ought to be the subject of a separate issue.

> A minor nit at L242 where the line break makes it harder to read.

I can change that before checking in.

Thanks,

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190301/b0c73ff1/attachment.html>


More information about the nio-dev mailing list