kotlinx-io
kotlinx-io copied to clipboard
[io-2] Bytes#append makes limits array too big
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
}