Fix panic when length of varints is greater than 8

It can be 16
This commit is contained in:
Jakub Sztandera
2016-11-17 18:45:34 +01:00
parent 5ec5bbcb48
commit 6ce8a80816

3
cid.go
View File

@@ -187,7 +187,8 @@ func (c *Cid) bytesV0() []byte {
}
func (c *Cid) bytesV1() []byte {
buf := make([]byte, 8+len(c.hash))
// two 8 bytes (max) numbers plus hash
buf := make([]byte, 2*8+len(c.hash))
n := binary.PutUvarint(buf, c.version)
n += binary.PutUvarint(buf[n:], c.codec)
copy(buf[n:], c.hash)