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

Avoid dereferencing a past-the-end iterator #13004

Merged
merged 1 commit into from Nov 29, 2021

Conversation

kronbichler
Copy link
Member

No description provided.

@@ -1307,7 +1307,8 @@ namespace Utilities
#else
(void)allow_compression;
#endif
fisb.push(boost::iostreams::array_source(&*cbegin, &*cend));
fisb.push(
boost::iostreams::array_source(&*cbegin, &*cbegin + (cend - cbegin)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example 34.3 of https://theboostcpplibraries.com/boost.iostreams-devices suggests that we could write this as

Suggested change
boost::iostreams::array_source(&*cbegin, &*cbegin + (cend - cbegin)));
boost::iostreams::array_source(&*cbegin, cend - cbegin));

Indeed, this overload exists: https://www.boost.org/doc/libs/1_76_0/libs/iostreams/doc/classes/array.html

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bangerth , I applied it.

@masterleinad masterleinad merged commit 9a23ab9 into dealii:master Nov 29, 2021
@kronbichler kronbichler deleted the avoid_invalid_memory_access branch May 11, 2022 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants