-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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::assign
and ::resize_and_overwrite
under ASan
#3956
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing my mistake -.-
The argument may alias `*this`, so don't shrink until after we copy the characters.
We need to update the buffer info even if we do not allocate.
Compare the converted "result size" to the "new size" so we don't need to suppress C4108. Improves readability and throughput a teeny bit.
string::assign
under ASanstring::assign
and ::resize_and_overwrite
under ASan
Sorry for my oversight😿 I've add a test for the problem introduced by my "fix". |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for fixing these bugs in one of the STL's most popular types and one of MSVC's most important new features! 😻 🐞 🛠️ |
Fixes #3955 / VSO-1854254 / AB#1854254 (fix string's self-assignment with offset via pointers under ASan)
Fixes VSO-1854245 / AB#1854245 "ASan issue in
basic_string::assign(pointer)
"Fixes VSO-1854251 / AB#1854251 "ASan issue in
basic_string::assign(iterator, iterator)
"Fixes VSO-1854242 / AB#1854242 "ASan issue in
tests/std/P0980R1_constexpr_strings
[basic_string::resize_and_overwrite
]"Drive-by: In
resize_and_overwrite
, compare the converted result size so we need not suppress the "comparing signed and unsigned" warning.Test coverage for the latter three fixes will be in the ASan test coverage that's incoming in the near future.