Skip to content

Commit

Permalink
add check to only read stream maximum
Browse files Browse the repository at this point in the history
  • Loading branch information
cfi2017 committed Apr 18, 2020
1 parent c274f1d commit c11977a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/item/bits.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ type Reader struct {
}

func (r *Reader) ReadInt(n int) (uint64, error) {
if len(r.stream)-n < 0 {
n = len(r.stream)
}
val, err := strconv.ParseUint(r.stream[len(r.stream)-n:], 2, 64)
r.stream = r.stream[:len(r.stream)-n]
return val, err
Expand Down

0 comments on commit c11977a

Please sign in to comment.