Fix a bug where a potential overflow occurs

This commit is contained in:
Cruz Julian Bishop 2012-06-29 13:38:53 +10:00
parent b11d4fa37a
commit c55e10c12a

View File

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