Skip to content

Commit a21e0ba

Browse files
authored
[clang-tidy] Fix buffer overflow in compareHeaders (#87213)
`RHS` can be shorter than `LHS`. Reported by asan after #83440.
1 parent 90c738e commit a21e0ba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int compareHeaders(StringRef LHS, StringRef RHS,
108108
IncludeSorter::IncludeStyle Style) {
109109
if (Style == IncludeSorter::IncludeStyle::IS_Google_ObjC) {
110110
const std::pair<const char *, const char *> &Mismatch =
111-
std::mismatch(LHS.begin(), LHS.end(), RHS.begin());
111+
std::mismatch(LHS.begin(), LHS.end(), RHS.begin(), RHS.end());
112112
if ((Mismatch.first != LHS.end()) && (Mismatch.second != RHS.end())) {
113113
if ((*Mismatch.first == '.') && (*Mismatch.second == '+')) {
114114
return -1;

0 commit comments

Comments
 (0)