Skip to content

Commit

Permalink
fix: Add handler for EndlessReader possible infinite lopp
Browse files Browse the repository at this point in the history
  • Loading branch information
wooffie committed Feb 10, 2025
1 parent 3867c34 commit c2ca26d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion msgp/circular.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ type EndlessReader struct {
offset int
}

// NewEndlessReader returns a new endless reader
// NewEndlessReader returns a new endless reader.
// Buffer b cannot be empty
func NewEndlessReader(b []byte, tb timer) *EndlessReader {
if len(b) == 0 {
panic("EndlessReader cannot be of zero length")
}
// Double until we reach 4K.
for len(b) < 4<<10 {
b = append(b, b...)
Expand Down

0 comments on commit c2ca26d

Please sign in to comment.