From 2c2c20224acb4743a20eb72331413e66ef8f8975 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 24 Jan 2012 14:19:59 -0800 Subject: [PATCH] encoding/binary: document that PutVarint, PutUvarint may panic Fixes #2628 R=golang-dev, gri CC=golang-dev https://golang.org/cl/5571058 --- src/pkg/encoding/binary/varint.go | 2 ++ 1 file changed, 2 insertions(+) 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 { -- 2.50.0