From ed4f413632a707488625401e162a2799c0877b6b Mon Sep 17 00:00:00 2001 From: Zeroday BYTE <47859767+odaysec@users.noreply.github.com> Date: Thu, 27 Feb 2025 19:34:13 +0700 Subject: [PATCH] Update buf.go --- internal/pkg/danger/buf.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/pkg/danger/buf.go b/internal/pkg/danger/buf.go index c1c00e746..3df682244 100644 --- a/internal/pkg/danger/buf.go +++ b/internal/pkg/danger/buf.go @@ -33,7 +33,11 @@ func (b *Buf) Reset() { } func (b *Buf) grow(n int) { - buf := make([]byte, len(b.buf), 2*cap(b.buf)+n) + newCap := 2*cap(b.buf) + n + if newCap < 0 { + panic("danger.Buf.grow: size computation overflow") + } + buf := make([]byte, len(b.buf), newCap) copy(buf, b.buf) b.buf = buf }