Skip to content

Commit

Permalink
[clang-tidy] Fix buffer overflow in compareHeaders (#87213)
Browse files Browse the repository at this point in the history
`RHS` can be shorter than `LHS`.

Reported by asan after #83440.
  • Loading branch information
vitalybuka committed Apr 1, 2024
1 parent 90c738e commit a21e0ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int compareHeaders(StringRef LHS, StringRef RHS,
IncludeSorter::IncludeStyle Style) {
if (Style == IncludeSorter::IncludeStyle::IS_Google_ObjC) {
const std::pair<const char *, const char *> &Mismatch =
std::mismatch(LHS.begin(), LHS.end(), RHS.begin());
std::mismatch(LHS.begin(), LHS.end(), RHS.begin(), RHS.end());
if ((Mismatch.first != LHS.end()) && (Mismatch.second != RHS.end())) {
if ((*Mismatch.first == '.') && (*Mismatch.second == '+')) {
return -1;
Expand Down

0 comments on commit a21e0ba

Please sign in to comment.