Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partition.java does not check the validity of input iterators #236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emopers
Copy link

@emopers emopers commented Jan 23, 2019

Partition.java calls j.previous() on java.util.Iterator j and i.next() on java.util.Iterator i
without checking if there are any elements to iterate over. Because the method is public and the iterators are obtained from inputs, they could be invalid (e.g., an empty list) and lead to an exception. This pull request adds a hasNext() and a hasPrevious() check.

This violation is present in other parts of this class as well. If this fix is acceptable to you, we can
submit another pull request with fixes for all other cases.

Fixing hasNext violation in a public class.
@ctrueden
Copy link
Member

Looks good to me! What do you think, @tpietzsch?

@ctrueden
Copy link
Member

I retract my LGTM; see #259 (comment).

@ctrueden
Copy link
Member

In #259 (comment), @tpietzsch wrote:

it should rather check i.nextIndex() < j.previousIndex() or something (I would need to think about the exact condition). Unfortunately, there is no way to check whether i and j are iterators into the same list, which is also an expectation about the input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants