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

Fix overflow in duplicates size hint #571

Closed

Conversation

bjchambers
Copy link

The math for size hint on duplicates would panic (with an overflow) if more elements were pending than remained in the size hint of the input iterator. This wasn't being tested since pending is only updated once some elements are advanced from the iterator.

This is actually pretty common, since collecting to a vector calls next first (before getting the size hint), for some reason related to branch prediction.

This adds an explicit test for collecting a vector from duplicates as well as a quick check case that skips elements before checking the size hint. It's not clear why the exhaustive check inside quickcheck wasn't catching this.

@phimuemue
Copy link
Member

Hi there, I think this is the same as #552.

But we should probably incorporate your quickcheck once we merge it.

@phimuemue
Copy link
Member

Closing because we already have #552.

@phimuemue phimuemue closed this Aug 15, 2021
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.

None yet

2 participants