[clang-tools-extra] [clang-tidy] Fix buffer overflow in compareHeaders (PR #87213)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 31 18:45:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
`RHS` can be shorter than `LHS`.
Reported by asan after #<!-- -->83440.
---
Full diff: https://github.com/llvm/llvm-project/pull/87213.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp (+1-1)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
index b6d9c50d0b109c..a44720c47eca2d 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/87213
More information about the cfe-commits
mailing list