From 804d8880141ce7046d1a76b2b158279d7c13c830 Mon Sep 17 00:00:00 2001 From: Camden Cheek Date: Tue, 16 Apr 2024 10:55:54 -0600 Subject: [PATCH] check for underflow --- contentprovider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentprovider.go b/contentprovider.go index 7ae13b43..a6b711c5 100644 --- a/contentprovider.go +++ b/contentprovider.go @@ -347,7 +347,7 @@ func (p *contentProvider) fillContentChunkMatches(ms []*candidateMatch, numConte // We want the line of the last byte in the match, not the first byte outside of the match. // For a zero-length match, endOffset-1 could be before match start, so fall back to the // byte after the match (as we do for startLine), not before. - max(startOffset, endOffset-1), + max(startOffset, max(endOffset, 1)-1 /* prevent underflow */), ) ranges = append(ranges, Range{