Skip to content

Commit

Permalink
fix: decoding error causing crash
Browse files Browse the repository at this point in the history
  • Loading branch information
tangtaoit committed Feb 6, 2024
1 parent 552aa03 commit 7d854d5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ func (d *Decoder) Binary() ([]byte, error) {
if err != nil {
return nil, err
}
if size < 0 {
return nil, fmt.Errorf("size is less than 0, size: %d", size)

}
if d.offset+int(size) > len(d.p) {
return nil, fmt.Errorf("Decoder couldn't read expect bytes %d of %d", d.offset+int(size), len(d.p))
}
Expand Down

0 comments on commit 7d854d5

Please sign in to comment.