kotlinx-io icon indicating copy to clipboard operation
kotlinx-io copied to clipboard

[io-2] Bytes#append makes limits array too big

Open pull-vert opened this issue 5 years ago • 0 comments
trafficstars

In Bytes#append function, limits seems to grow too big. This is current code with a comment that shows the problem

if (tail == buffers.size) {
    buffers = buffers.copyInto(arrayOfNulls(buffers.size * 2))
    // buffers has now a size = 2 * old size
    limits = limits.copyInto(IntArray(buffers.size * 2))
    // FIXME incorrect ! here limits size = 2 * new buffer size = 4 * old buffer size
    // should be equal to new buffer size
}

pull-vert avatar Jan 18 '20 15:01 pull-vert