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 subscript out of range in autovector.h #379

Merged
merged 1 commit into from
Jan 18, 2021
Merged

fix subscript out of range in autovector.h #379

merged 1 commit into from
Jan 18, 2021

Conversation

shencebebetterme
Copy link
Contributor

In "autovector.h", the length of the std::vector dat_ is equal to 1+maxi_-mini_+miniloc_, therefore in the expression dat_[1+maxi_-mini_+miniloc_] the subscript definitely goes out of range.

Previously this issue causes no error because on Linux and on mac std::vector does not perform a bound check and returns whatever in the memory as the out-of-range element. The end() thus obtained still points to the correct memory, however, the above behaviour is undefined and should be avoided.

The fixes are easy.

@emstoudenmire
Copy link
Contributor

Thank you for this fix - it's a welcome improvement!

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