Skip to content

Commit 2436e1f

Browse files
committed
add read-only Bytes reader index bounds checks
1 parent ccb65f3 commit 2436e1f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/io/appulse/utils/BytesReadOnly.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ public int readerIndex () {
230230

231231
@Override
232232
public Bytes readerIndex (int newIndex) {
233+
if (newIndex < 0 || newIndex > writerIndex()) {
234+
val msg = String.format(
235+
"Reader index error: newIndex(%d) < 0 || newIndex(%d) > writerIndex(%d)",
236+
newIndex, newIndex, writerIndex()
237+
);
238+
throw new IndexOutOfBoundsException(msg);
239+
}
233240
readerIndex = newIndex;
234241
return this;
235242
}

0 commit comments

Comments
 (0)