From 4a1b934cfaca01dc27e4d0b89a55470b6404a703 Mon Sep 17 00:00:00 2001 From: BSdrop Date: Thu, 14 May 2026 13:08:29 +0000 Subject: [PATCH] Potential fix for code scanning alert no. 4: Size computation for allocation may overflow Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- internal/scraper/modified.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/scraper/modified.go b/internal/scraper/modified.go index 9f52f4d..66dc2ac 100644 --- a/internal/scraper/modified.go +++ b/internal/scraper/modified.go @@ -55,8 +55,16 @@ func buildModifiedEvents(path string, newData []byte, kind, scopeKind string, sc } oldMap := mapRawByID(oldPage.Results) - ids := make([]int64, 0, len(oldMap)+len(newMap)) - seen := make(map[int64]struct{}, len(oldMap)+len(newMap)) + oldLen := len(oldMap) + newLen := len(newMap) + maxInt := int(^uint(0) >> 1) + if oldLen > maxInt-newLen { + return nil, fmt.Errorf("too many tracked items") + } + total := oldLen + newLen + + ids := make([]int64, 0, total) + seen := make(map[int64]struct{}, total) for id := range oldMap { seen[id] = struct{}{} ids = append(ids, id)