Skip to content

Commit 4a73961

Browse files
committed
feat(): fix decode bundle item stream tags is 0 bug
1 parent 760c993 commit 4a73961

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

utils/bundle.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,16 @@ func DecodeBundleItemStream(itemBinary io.Reader) (*types.BundleItem, error) {
383383
}
384384
numOfTags := ByteArrayToLong(numOfTagsBy)
385385

386-
var tagsBytesLength int
386+
tagsBytesLengthBy := make([]byte, 8, 8)
387+
n, err = itemBinary.Read(tagsBytesLengthBy)
388+
if err != nil || n < 8 {
389+
return nil, errors.New("itemBinary incorrect")
390+
}
391+
tagsBytesLength := ByteArrayToLong(tagsBytesLengthBy)
392+
387393
tags := []types.Tag{}
388394
tagsBytes := make([]byte, 0)
389395
if numOfTags > 0 {
390-
tagsBytesLengthBy := make([]byte, 8, 8)
391-
n, err = itemBinary.Read(tagsBytesLengthBy)
392-
if err != nil || n < 8 {
393-
return nil, errors.New("itemBinary incorrect")
394-
}
395-
tagsBytesLength = ByteArrayToLong(tagsBytesLengthBy)
396396
tagsBytes = make([]byte, tagsBytesLength, tagsBytesLength)
397397
n, err = itemBinary.Read(tagsBytes)
398398
if err != nil || n < tagsBytesLength {

0 commit comments

Comments
 (0)