fastutil icon indicating copy to clipboard operation
fastutil copied to clipboard

Error in ImmutableSubList.ListIterator#hasNext

Open meztihn opened this issue 2 years ago • 2 comments

Example:

var iterator = IntList.of(1, 1).subList(1, 2).iterator();
while (iterator.hasNext()) iterator.nextInt();

throws java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2. It's reproducible with DoubleList as well. Haven't checked other types though.

Possible workaround: replace IntList with IntArrayList.

Affected version: fastutil-core:8.5.12.

I guess, the problem is in missing addition of from inside hasNext method.

meztihn avatar Oct 19 '23 13:10 meztihn

Sounds like a (hopefully) simple fix; I can try to make a merge request for it

techsy730 avatar Dec 03 '23 23:12 techsy730

Ouch, I completely missed this somehow. Yes, if you can fix it in a PR that'd be great. I'd like to fix a few things and release.

vigna avatar Dec 04 '23 12:12 vigna