Skip to content

Commit 60928cc

Browse files
committed
bugs out of bound
Signed-off-by: phmai <phuc.mai@here.com>
1 parent 12045b9 commit 60928cc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

here-naksha-lib-base/src/jvmMain/java/naksha/base/JsonArray.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ public int lastIndexOf(@Nullable Object o) {
392392

393393
@Override
394394
public @NotNull ListIterator<@Nullable Object> listIterator(final int fromIndex) {
395+
if (fromIndex < 0 || fromIndex > length) {
396+
throw new IndexOutOfBoundsException("Index: "+fromIndex+", JsonArray size: "+size());
397+
}
395398
return new ListIterator<>() {
396399
private int index = fromIndex;
397400
private boolean canRemove = false;
@@ -446,7 +449,7 @@ public void remove() {
446449

447450
@Override
448451
public void set(Object o) {
449-
if (!lastMoveWasNext && index == 0) {
452+
if (!canRemove) {
450453
throw new IllegalStateException();
451454
}
452455
if (lastMoveWasNext) {

0 commit comments

Comments
 (0)