From a177d70ab68bf113ce04848cc8de9bcc84b6ac07 Mon Sep 17 00:00:00 2001 From: Yanhu007 Date: Tue, 14 Apr 2026 16:10:36 +0800 Subject: [PATCH] fix: prevent panic in Row.matchAll on slice bounds out of range Row.matchAll could panic with "slice bounds out of range" when the computed end index exceeded the string length. This happened with certain malformed glob patterns like "/{a{*.json{" matched against valid paths. Add a bounds check before slicing to prevent the panic. Fixes #59 --- match/row.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/match/row.go b/match/row.go index 4379042..2495451 100644 --- a/match/row.go +++ b/match/row.go @@ -31,11 +31,12 @@ func (self Row) matchAll(s string) bool { } } - if i < length || !m.Match(s[idx:idx+next+1]) { + end := idx + next + 1 + if i < length || end > len(s) || !m.Match(s[idx:end]) { return false } - idx += next + 1 + idx = end } return true