]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/binary: document that PutVarint, PutUvarint may panic
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 24 Jan 2012 22:19:59 +0000 (14:19 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 24 Jan 2012 22:19:59 +0000 (14:19 -0800)
Fixes #2628

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5571058

src/pkg/encoding/binary/varint.go

index 6566ab0600e5af7211332590bac8cfe92bfd834d..b756afdd0400cccbdd839c8907490c0e42befa98 100644 (file)
@@ -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 {