Fix capacity check bug affecting offheap buffers
This commit is contained in:
parent
e29f8231aa
commit
d547b5d51d
@ -274,7 +274,7 @@ final class PooledDirectByteBuf extends PooledByteBuf<ByteBuffer> {
|
||||
|
||||
@Override
|
||||
public ByteBuf setBytes(int index, ByteBuffer src) {
|
||||
checkIndex(index);
|
||||
checkIndex(index, src.remaining());
|
||||
ByteBuffer tmpBuf = internalNioBuffer();
|
||||
if (src == tmpBuf) {
|
||||
src = src.duplicate();
|
||||
|
@ -278,7 +278,7 @@ final class PooledUnsafeDirectByteBuf extends PooledByteBuf<ByteBuffer> {
|
||||
|
||||
@Override
|
||||
public ByteBuf setBytes(int index, ByteBuffer src) {
|
||||
checkIndex(index);
|
||||
checkIndex(index, src.remaining());
|
||||
ByteBuffer tmpBuf = internalNioBuffer();
|
||||
if (src == tmpBuf) {
|
||||
src = src.duplicate();
|
||||
|
@ -16,6 +16,7 @@
|
||||
package io.netty.buffer;
|
||||
|
||||
import io.netty.util.CharsetUtil;
|
||||
import io.netty.util.internal.EmptyArrays;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
@ -163,6 +164,8 @@ public abstract class AbstractByteBufTest {
|
||||
buffer.writerIndex(0);
|
||||
buffer.readerIndex(0);
|
||||
buffer.writerIndex(CAPACITY);
|
||||
|
||||
buffer.writeBytes(ByteBuffer.wrap(EmptyArrays.EMPTY_BYTES));
|
||||
}
|
||||
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
|
Loading…
Reference in New Issue
Block a user