Skip to content

fix underflow in vec swap_remove #16203

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

Merged
merged 1 commit into from
Aug 3, 2014
Merged

fix underflow in vec swap_remove #16203

merged 1 commit into from
Aug 3, 2014

Conversation

Gankra
Copy link
Contributor

@Gankra Gankra commented Aug 2, 2014

fixes #16200

@alexcrichton
Copy link
Member

Can you add a test for this as well?

@Gankra
Copy link
Contributor Author

Gankra commented Aug 2, 2014

@alexcrichton oh of course. Is this test sufficient, or should we add more test cases for the rest of swap_remove?

@huonw
Copy link
Member

huonw commented Aug 2, 2014

Testing just index + 1 < length is possibly more efficient than the two comparisons.

@Gankra
Copy link
Contributor Author

Gankra commented Aug 3, 2014

@huonw: would that not be the same problem for index = length = uint::MAX? Or are you suggesting using CheckedAdd? Although I supposed length = uint::MAX is already bordering on madness.

bors added a commit that referenced this pull request Aug 3, 2014
@bors bors closed this Aug 3, 2014
@bors bors merged commit d9b2e6b into rust-lang:master Aug 3, 2014
@Gankra Gankra deleted the vec_flow branch August 18, 2014 19:09
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.

Vec::swap_remove fails if the vector is empty.
4 participants