[#1060] Fix bug in CompositeByteBuf which let the buffer expand in a incorrect way and so result in corrupted data
This commit is contained in:
parent
891cf343ca
commit
4ed5b07e4e
@ -451,7 +451,7 @@ public class DefaultCompositeByteBuf extends AbstractReferenceCountedByteBuf
|
||||
if (nComponents < maxNumComponents) {
|
||||
padding = allocBuffer(paddingLength);
|
||||
padding.setIndex(0, paddingLength);
|
||||
addComponent0(0, padding);
|
||||
addComponent0(components.size(), padding);
|
||||
} else {
|
||||
padding = allocBuffer(paddingLength);
|
||||
padding.setIndex(0, paddingLength);
|
||||
|
@ -418,4 +418,16 @@ public abstract class AbstractCompositeByteBufTest extends
|
||||
b.readBytes(new byte[4]);
|
||||
b.readBytes(new byte[0]);
|
||||
}
|
||||
|
||||
// Test for https://github.com/netty/netty/issues/1060
|
||||
@Test
|
||||
public void testReadWithEmptyCompositeBuffer() {
|
||||
ByteBuf buf = compositeBuffer();
|
||||
int n = 65;
|
||||
for (int i=0; i<n; ++i) {
|
||||
buf.writeByte(1);
|
||||
assertEquals(1, buf.readByte());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user