Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: fix Conn.Next and Conn.Peek panic On Unix #616

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions connection_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,13 @@
}
head, tail := c.inboundBuffer.Peek(n)
defer c.inboundBuffer.Discard(n) //nolint:errcheck
if len(head) == n {
if len(head) >= n {

Check warning on line 328 in connection_unix.go

View check run for this annotation

Codecov / codecov/patch

connection_unix.go#L328

Added line #L328 was not covered by tests
return head[:n], err
}
c.loop.cache.Reset()
c.loop.cache.Write(head)
c.loop.cache.Write(tail)
if inBufferLen == n {
if inBufferLen >= n {

Check warning on line 334 in connection_unix.go

View check run for this annotation

Codecov / codecov/patch

connection_unix.go#L334

Added line #L334 was not covered by tests
return c.loop.cache.Bytes(), err
}

Expand All @@ -352,13 +352,13 @@
return c.buffer[:n], err
}
head, tail := c.inboundBuffer.Peek(n)
if len(head) == n {
if len(head) >= n {
return head[:n], err
}
c.loop.cache.Reset()
c.loop.cache.Write(head)
c.loop.cache.Write(tail)
if inBufferLen == n {
if inBufferLen >= n {
return c.loop.cache.Bytes(), err
}

Expand Down
Loading