Avoid selecting an outdated merger from cache

We cache a merger for partial input as well, because it is automatically
invalidated as soon as the new data comes in.

However, there was a race condition where a cached merger for a partial
input is used even after the input stream was complete. This commit
fixes the problem.

Fix #4034
This commit is contained in:
Junegunn Choi 2024-10-16 00:27:56 +09:00
parent 97f1dae2d1
commit 90a8800bb5
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -102,7 +102,7 @@ func (m *Matcher) Loop() {
if !cacheCleared {
if count == prevCount {
// Look up mergerCache
if cached, found := m.mergerCache[patternString]; found {
if cached, found := m.mergerCache[patternString]; found && cached.final == request.final {
merger = cached
}
} else {