From 6cfbd9c03583d35fa8821f647d36c3d63f462d31 Mon Sep 17 00:00:00 2001 From: Junjie Gao Date: Thu, 3 Aug 2023 19:47:39 +0800 Subject: [PATCH] fix: update code Signed-off-by: Junjie Gao --- internal/encoding/asn1/asn1.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/encoding/asn1/asn1.go b/internal/encoding/asn1/asn1.go index c8ef6abc..398912b0 100644 --- a/internal/encoding/asn1/asn1.go +++ b/internal/encoding/asn1/asn1.go @@ -89,12 +89,12 @@ func decode(r []byte) (value, error) { // top v := valueStack[stackLen-1] - // the constructed value has been docoded + // check that the constructed value is fully encoded if len(v.rawContent) == 0 { + // calculate the length of the members for _, m := range v.members { v.length += m.EncodedLen() } - // pop valueStack = valueStack[:stackLen-1] continue @@ -122,6 +122,8 @@ func decode(r []byte) (value, error) { rawContent: v.rawContent[:contentLen], } v.members = append(v.members, &cv) + + // add a new constructed node to the stack valueStack = append(valueStack, &cv) } v.rawContent = v.rawContent[contentLen:]