Fix an infinite loop in DefaultCompositeByteBuf.setBytes()

This commit is contained in:
Trustin Lee 2012-08-08 17:42:58 +09:00
parent a2aadef4da
commit 501746aeff

View File

@ -884,6 +884,18 @@ public class DefaultCompositeByteBuf extends AbstractByteBuf implements Composit
int localLength = Math.min(length, s.capacity() - (index - adjustment));
int localReadBytes = s.setBytes(index - adjustment, in, localLength);
if (localReadBytes == 0) {
break;
}
if (localReadBytes < 0) {
if (readBytes == 0) {
return -1;
} else {
break;
}
}
if (localReadBytes == localLength) {
index += localLength;
length -= localLength;