From 27425c15c4b96f1e11db8cc496b48f3d0fc0d3f4 Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Sun, 31 Jul 2022 16:37:26 +0200 Subject: [PATCH] autocompletion: fix slice out of bounds access Signed-off-by: Moritz Poldrack Acked-by: Robin Jarry --- lib/ui/textinput.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go index 8bc32b0..f09ebb4 100644 --- a/lib/ui/textinput.go +++ b/lib/ui/textinput.go @@ -70,6 +70,9 @@ func (ti *TextInput) String() string { } func (ti *TextInput) StringLeft() string { + for ti.index >= len(ti.text) { + ti.index = len(ti.text) - 1 + } return string(ti.text[:ti.index]) }