m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-12-06 17:24:07 -05:00

Do not allow very long queries in FuzzyMatchV2

Close #4608
This commit is contained in:
Junegunn Choi
2025-11-28 18:41:45 +09:00
parent 1d5e87f5e4
commit 60a5be1e65

View File

@@ -445,7 +445,9 @@ func FuzzyMatchV2(caseSensitive bool, normalize bool, forward bool, input *util.
// Since O(nm) algorithm can be prohibitively expensive for large input, // Since O(nm) algorithm can be prohibitively expensive for large input,
// we fall back to the greedy algorithm. // we fall back to the greedy algorithm.
if slab != nil && N*M > cap(slab.I16) { // Also, we should not allow a very long pattern to avoid 16-bit integer
// overflow in the score matrix. 1000 is a safe limit.
if slab != nil && N*M > cap(slab.I16) || M > 1000 {
return FuzzyMatchV1(caseSensitive, normalize, forward, input, pattern, withPos, slab) return FuzzyMatchV1(caseSensitive, normalize, forward, input, pattern, withPos, slab)
} }