tape: Fix negative slice length

This commit is contained in:
Sasha Koshka 2025-07-04 14:18:30 -04:00
parent c8a2f03ca1
commit 5989a82bee

View File

@ -129,7 +129,7 @@ func decodeAny(decoder *Decoder, destination reflect.Value, tag Tag) (n int, err
return n, errWrongDestinationType("slice") return n, errWrongDestinationType("slice")
} }
if destination.Cap() < int(length) { if destination.Cap() < int(length) {
destination.Grow(destination.Cap() - int(length)) destination.Grow(int(length) - destination.Cap())
} }
destination.SetLen(int(length)) destination.SetLen(int(length))
for index := range length { for index := range length {