From e0451d6a607b9693af15344b5b0fa0e14cc8bb13 Mon Sep 17 00:00:00 2001 From: majiayu000 <1835304752@qq.com> Date: Wed, 31 Dec 2025 07:48:39 +0800 Subject: [PATCH] fix: add bounds checking in findHyperlinkAt to prevent panic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add defensive bounds checking in findHyperlinkAt() to prevent "runtime error: index out of range [0] with length 0" panic. This handles race conditions where viewLines may change between the caller's bounds check and the function's access. Fixes #5148 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 Signed-off-by: majiayu000 <1835304752@qq.com> --- vendor/github.com/jesseduffield/gocui/view.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/vendor/github.com/jesseduffield/gocui/view.go index e5b5c046646..c817f244652 100644 --- a/vendor/github.com/jesseduffield/gocui/view.go +++ b/vendor/github.com/jesseduffield/gocui/view.go @@ -1896,6 +1896,14 @@ func (v *View) onMouseMove(x int, y int) { } func (v *View) findHyperlinkAt(x, y int) *SearchPosition { + // Bounds check to prevent index out of range panic + if y < 0 || y >= len(v.viewLines) { + return nil + } + if x < 0 || x >= len(v.viewLines[y].line) { + return nil + } + linkStr := v.viewLines[y].line[x].hyperlink if linkStr == "" { return nil