diff options
| author | Jon Roelofs <jonathan_roelofs@apple.com> | 2025-07-23 08:40:11 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-23 08:40:11 -0700 |
| commit | a7867fcd94555fb056bcaac66de45d4635da99bf (patch) | |
| tree | 806e30d427e3f416bc1a308bc0b57edbf5286330 /llvm/lib/FileCheck/FileCheck.cpp | |
| parent | f4d0d124cb5e2157d32aef69d9ab52abcea7fb23 (diff) | |
[FileCheck] Limit quadratic partial-match search behavior (#147833)
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
| -rw-r--r-- | llvm/lib/FileCheck/FileCheck.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index b79f6ec5b4f0..ce35a5bad761 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -1360,6 +1360,12 @@ void Pattern::printFuzzyMatch(const SourceMgr &SM, StringRef Buffer, size_t Best = StringRef::npos; double BestQuality = 0; + // Arbitrarily limit quadratic search behavior stemming from long CHECK lines. + if (size_t(4096) * size_t(2048) < + std::min(size_t(4096), Buffer.size()) * + std::max(FixedStr.size(), RegExStr.size())) + return; + // Use an arbitrary 4k limit on how far we will search. for (size_t i = 0, e = std::min(size_t(4096), Buffer.size()); i != e; ++i) { if (Buffer[i] == '\n') |
