Skip to content

Commit

Permalink
Merge pull request #41 from dreamscached/issue-40-fix
Browse files Browse the repository at this point in the history
Fix #40 by using minInt
  • Loading branch information
dreamscached authored Dec 22, 2022
2 parents 65a318e + 8f6a4c3 commit b404c1b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ping_17.go
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ func (p *Pinger) ping17ReadStatusResponsePacketPayload(reader io.Reader) ([]byte

// Read entire packet to a buffer
pb := bytes.NewBuffer(make([]byte, 0, pl))
pb.Write(lb[ln-lr.Len() : ln])
pb.Write(lb[maxInt(ln-lr.Len(), 0):ln])
if _, err = io.CopyN(pb, reader, int64(pl)-int64(lr.Len())); err != nil {
return nil, err
}
Expand Down
9 changes: 9 additions & 0 deletions stack.go → util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ func (s *stack) Pop() (interface{}, error) {
*s = (*s)[0 : len(*s)-1]
return ret, nil
}

// maxInt returns greatest of two of the passed integer numbers.
func maxInt(a int, b int) int {
if a < b {
return b
} else {
return a
}
}

0 comments on commit b404c1b

Please sign in to comment.