Skip to content

Commit

Permalink
bug: fix the issue of panic: runtime error: slice bounds out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Nov 29, 2021
1 parent 24967fe commit 30311e9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ringbuffer/ring_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ func (rb *RingBuffer) CopyFromSocket(fd int, read func(int, []byte) (int, error)
n, err = read(fd, rb.buf[rb.w:])
if n > 0 {
rb.isEmpty = false
}
rb.w += n
if rb.w == rb.size {
rb.w = 0
rb.w += n
if rb.w == rb.size {
rb.w = 0
}
}
return
}
Expand Down

0 comments on commit 30311e9

Please sign in to comment.