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 string::replace under ASan #3884

Merged
merged 3 commits into from
Jul 20, 2023

Conversation

strega-nil-ms
Copy link
Contributor

Fixes #3883

@strega-nil-ms strega-nil-ms requested a review from a team as a code owner July 17, 2023 21:58
@CaseyCarter CaseyCarter added the bug Something isn't working label Jul 17, 2023
@StephanTLavavej StephanTLavavej added the ASan Address Sanitizer label Jul 18, 2023
Comment on lines 3809 to 3811
const auto _New_size = _Old_size + _Count - _Nx;
_ASAN_STRING_MODIFY(*this, _Old_size, _New_size);
_ASAN_STRING_REMOVE(*this);
_Mypair._Myval2._Mysize = _New_size;
Copy link
Member

Choose a reason for hiding this comment

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

No change requested: We could fuse _New_size now, or move its definition below the _ASAN_STRING_REMOVE. This is fine as-is though.

@StephanTLavavej StephanTLavavej self-assigned this Jul 20, 2023
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 8a93121 into microsoft:main Jul 20, 2023
@StephanTLavavej
Copy link
Member

Thanks for this important ASAN fix! 🐞 🛠️ 🎉

@strega-nil-ms strega-nil-ms deleted the asan-string-replace branch July 26, 2023 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASan Address Sanitizer bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<string>: basic_string::replace fails under ASan when pos + count > size, and count2 < count
5 participants