Improve bounds checking.

This commit is contained in:
Andy Nguyen 2021-11-08 20:03:30 +01:00
parent 05adae5e31
commit 8d11f3545a

View File

@ -89,7 +89,7 @@ public class Buffer {
}
private void checkOffset(int offset, int length) {
if (offset < 0 || (offset + length) > size) {
if (offset < 0 || length < 0 || (offset + length) > size) {
throw new IndexOutOfBoundsException();
}
}