From 93c0cffda66eea8ee46326365735613cb1d0dc29 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 11 May 2024 02:04:55 +0200 Subject: [PATCH] wip --- lib/encoding/int.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/encoding/int.go b/lib/encoding/int.go index cccc9ebad..445345aeb 100644 --- a/lib/encoding/int.go +++ b/lib/encoding/int.go @@ -361,9 +361,11 @@ func marshalVarUint64sSlow(dst []byte, us []uint64) []byte { // UnmarshalVarUint64 returns unmarshaled uint64 from src and returns // the remaining tail from src. func UnmarshalVarUint64(src []byte) ([]byte, uint64, error) { - var tmp [1]uint64 - tail, err := UnmarshalVarUint64s(tmp[:], src) - return tail, tmp[0], err + u64, offset := binary.Uvarint(src) + if offset <= 0 { + return src, 0, fmt.Errorf("cannot read varuint64") + } + return src[offset:], u64, nil } // UnmarshalVarUint64s unmarshals len(dst) uint64 values from src to dst