Skip to content

Commit

Permalink
upgrade Go
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Jun 7, 2024
1 parent 9d2a157 commit 223630e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.sia.tech/core

go 1.20
go 1.21.8

require (
go.sia.tech/mux v1.2.0
Expand Down
15 changes: 2 additions & 13 deletions types/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,9 @@ func (d *Decoder) Err() error { return d.err }
func (d *Decoder) Read(p []byte) (int, error) {
n := 0
for len(p[n:]) > 0 && d.err == nil {
want := len(p[n:])
if want > len(d.buf) {
want = len(d.buf)
}
read, err := io.ReadFull(&d.lr, d.buf[:want])
if err != nil {
// When the decoder encounters an error, it must clear its buffer and
// return empty values for the remaining decodes. Because the decoder uses
// sticky errors instead of immediately returning a bad decode can
// potentially cause a massive allocation.
d.SetErr(err)
return n, err
}
read, err := io.ReadFull(&d.lr, d.buf[:min(len(p[n:]), len(d.buf))])
n += copy(p[n:], d.buf[:read])
d.SetErr(err)
}
return n, d.err
}
Expand Down

0 comments on commit 223630e

Please sign in to comment.