Skip to content

Commit

Permalink
fix bug: slice bounds out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjunbiao committed Mar 30, 2021
1 parent 37c4db4 commit a22041f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions primitive_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package y3

import (
"errors"
"fmt"

"github.com/yomorun/y3-codec-golang/pkg/encoding"

Expand Down Expand Up @@ -53,6 +54,9 @@ func DecodePrimitivePacket(buf []byte) (packet *PrimitivePacket, endPos int, siz

logger.Debugf(">>> sizeL=%v, length=%v, pos=%v, endPos=%v", sizeL, p.length, pos, endPos)

if pos > endPos {
return nil, 0, sizeL, fmt.Errorf("beyond the boundary, pos=%v, endPos=%v", pos, endPos)
}
p.valBuf = buf[pos:endPos]
logger.Debugf("valBuf = %#X", p.valBuf)

Expand Down

0 comments on commit a22041f

Please sign in to comment.