Skip to content

Commit ea02415

Browse files
committed
Fix snapref, too
1 parent 41124a6 commit ea02415

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/snapref/encode.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ import (
2020
func Encode(dst, src []byte) []byte {
2121
if n := MaxEncodedLen(len(src)); n < 0 {
2222
panic(ErrTooLarge)
23-
} else if len(dst) < n {
23+
} else if cap(dst) < n {
2424
dst = make([]byte, n)
25+
} else {
26+
dst = dst[:n]
2527
}
2628

2729
// The block starts with the varint-encoded length of the decompressed bytes.

0 commit comments

Comments
 (0)