Fix a bug in MemSegBuffer

This commit is contained in:
Chris Vest 2021-05-28 13:54:16 +02:00
parent a6b81c89ef
commit 0aa2853cf3

View File

@ -299,6 +299,9 @@ class MemSegBuffer extends ResourceSupport<Buffer, MemSegBuffer> implements Buff
@Override
public Buffer copy(int offset, int length) {
checkGet(offset, length);
if (length < 0) {
throw new IllegalArgumentException("Length cannot be negative: " + length + '.');
}
if (length == 0) {
// Special case zero-length segments, since allocators don't support allocating empty buffers.