From d9d2e3131803f2d4afa8088ac17341558830e4cf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 7 Apr 2023 18:08:38 +0530 Subject: [PATCH] Another place where [:max_length] is used without checking --- kittens/unicode_input/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kittens/unicode_input/main.go b/kittens/unicode_input/main.go index 372a2c7c7..23ec554eb 100644 --- a/kittens/unicode_input/main.go +++ b/kittens/unicode_input/main.go @@ -599,7 +599,10 @@ func run_loop(opts *Options) (lp *loop.Loop, err error) { if idx > -1 { cached_data.Recent = slices.Delete(cached_data.Recent, idx, idx+1) } - cached_data.Recent = slices.Insert(cached_data.Recent, 0, h.current_char)[:len(DEFAULT_SET)] + cached_data.Recent = slices.Insert(cached_data.Recent, 0, h.current_char) + if len(cached_data.Recent) > len(DEFAULT_SET) { + cached_data.Recent = cached_data.Recent[:len(DEFAULT_SET)] + } ans := h.resolved_char() o, err := output(ans) if err != nil {