channel buffer: bytesBefore bounds checking
This commit is contained in:
parent
d210702b4e
commit
8b4152dbe0
@ -610,6 +610,9 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
}
|
||||
|
||||
public int bytesBefore(int index, int length, byte value) {
|
||||
if (index < 0 || length < 0 || index + length > capacity()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
int endIndex = indexOf(index, index + length, value);
|
||||
if (endIndex < 0) {
|
||||
return -1;
|
||||
@ -619,6 +622,9 @@ public abstract class AbstractChannelBuffer implements ChannelBuffer {
|
||||
|
||||
public int bytesBefore(int index, int length,
|
||||
ChannelBufferIndexFinder indexFinder) {
|
||||
if (index < 0 || length < 0 || index + length > capacity()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
int endIndex = indexOf(index, index + length, indexFinder);
|
||||
if (endIndex < 0) {
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user