Fix off-by-one error that could panic.
parent
bc4282ad99
commit
f131d3cc77
|
@ -625,13 +625,13 @@ func DecodeStringBlock(block []byte, tdec *TimeDecoder, vdec *StringDecoder, a *
|
|||
func packBlock(buf []byte, typ byte, ts []byte, values []byte) []byte {
|
||||
// We encode the length of the timestamp block using a variable byte encoding.
|
||||
// This allows small byte slices to take up 1 byte while larger ones use 2 or more.
|
||||
sz := 1 + 10 + len(ts) + len(values)
|
||||
sz := 1 + binary.MaxVarintLen64 + len(ts) + len(values)
|
||||
if cap(buf) < sz {
|
||||
buf = make([]byte, sz)
|
||||
}
|
||||
b := buf[:sz]
|
||||
b[0] = typ
|
||||
i := binary.PutUvarint(b[1:10], uint64(len(ts)))
|
||||
i := binary.PutUvarint(b[1:1+binary.MaxVarintLen64], uint64(len(ts)))
|
||||
i += 1
|
||||
|
||||
// block is <len timestamp bytes>, <ts bytes>, <value bytes>
|
||||
|
|
Loading…
Reference in New Issue