From 90a8800bb596cd98e103788096f2780ee97100b4 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 16 Oct 2024 00:27:56 +0900 Subject: [PATCH] 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 --- src/matcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matcher.go b/src/matcher.go index 4e21f8ca..49d39730 100644 --- a/src/matcher.go +++ b/src/matcher.go @@ -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 {