Update handler.go

This commit is contained in:
Maxim Evtush 2026-01-07 17:05:17 +02:00 committed by GitHub
parent 957a3602d9
commit e391903879
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -612,8 +612,11 @@ type limitedBuffer struct {
} }
func (buf *limitedBuffer) Write(data []byte) (int, error) { func (buf *limitedBuffer) Write(data []byte) (int, error) {
avail := max(buf.limit, len(buf.output)) avail := buf.limit - len(buf.output)
if len(data) < avail { if avail <= 0 {
return 0, errTruncatedOutput
}
if len(data) <= avail {
buf.output = append(buf.output, data...) buf.output = append(buf.output, data...)
return len(data), nil return len(data), nil
} }