Fix a bug where a potential overflow occurs

This commit is contained in:
Cruz Julian Bishop 2012-06-29 13:38:53 +10:00 committed by Trustin Lee
parent 0f6c3137f6
commit dc300f2c81

View File

@ -592,7 +592,7 @@ public class CompositeByteBuf extends AbstractByteBuf {
* less than zero, or larger than {@code capacity()} * less than zero, or larger than {@code capacity()}
*/ */
public ByteBuf getBufferFor(int index) throws IndexOutOfBoundsException { public ByteBuf getBufferFor(int index) throws IndexOutOfBoundsException {
if (index < 0 || index > capacity()) { if (index < 0 || index >= capacity()) {
throw new IndexOutOfBoundsException("Invalid index: " + index throw new IndexOutOfBoundsException("Invalid index: " + index
+ " - Bytes needed: " + index + ", maximum is " + " - Bytes needed: " + index + ", maximum is "
+ capacity()); + capacity());