From ef3f5cf4bb8c039f416651511365ae7b5c1f91d3 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 12 Oct 2025 11:34:49 -0400 Subject: [PATCH] tape: Decode KTV into any --- tape/dynamic.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tape/dynamic.go b/tape/dynamic.go index 120eb50..31966b6 100644 --- a/tape/dynamic.go +++ b/tape/dynamic.go @@ -240,8 +240,16 @@ func decodeAnyOrError(decoder *Decoder, destination reflect.Value, tag Tag) (n i if length > uint64(MaxStructureLength) { return 0, ErrTooLong } + lengthCast, err := Uint64ToIntSafe(length) + if err != nil { return n, err } + if isTypeAny(destination.Type()) { + // need a skeleton value if we are assigning to any. + value := reflect.MakeMapWithSize(reflect.TypeOf(dummyMap), lengthCast) + destination.Set(value) + destination = value + } destination.Clear() - for _ = range length { + for _ = range lengthCast { key, nn, err := decoder.ReadUint16() n += nn; if err != nil { return n, err } itemTag, nn, err := decoder.ReadTag()