From: Brad Fitzpatrick Date: Tue, 24 Jan 2012 22:19:59 +0000 (-0800) Subject: encoding/binary: document that PutVarint, PutUvarint may panic X-Git-Tag: weekly.2012-01-27~69 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2c2c20224acb4743a20eb72331413e66ef8f8975;p=gostls13.git encoding/binary: document that PutVarint, PutUvarint may panic Fixes #2628 R=golang-dev, gri CC=golang-dev https://golang.org/cl/5571058 --- diff --git a/src/pkg/encoding/binary/varint.go b/src/pkg/encoding/binary/varint.go index 6566ab0600..b756afdd04 100644 --- a/src/pkg/encoding/binary/varint.go +++ b/src/pkg/encoding/binary/varint.go @@ -37,6 +37,7 @@ const ( ) // PutUvarint encodes a uint64 into buf and returns the number of bytes written. +// If the buffer is too small, PutUvarint will panic. func PutUvarint(buf []byte, x uint64) int { i := 0 for x >= 0x80 { @@ -73,6 +74,7 @@ func Uvarint(buf []byte) (uint64, int) { } // PutVarint encodes an int64 into buf and returns the number of bytes written. +// If the buffer is too small, PutVarint will panic. func PutVarint(buf []byte, x int64) int { ux := uint64(x) << 1 if x < 0 {