reader.go | 3 +-- storage/wrappers.go | 4 ++-- diff --git a/reader.go b/reader.go index 5c3bccada2fb743dbfac9eab4ec2d6d3a1af9613..bdfeed04047fa2001668dea64e87353d2ee7abcc 100644 --- a/reader.go +++ b/reader.go @@ -193,11 +193,10 @@ err = *ctxErr return } } - b1 := b[:avail] pi := int(pos / r.t.info.PieceLength) ip := r.t.info.Piece(pi) po := pos % r.t.info.PieceLength - missinggo.LimitLen(&b1, ip.Length()-po) + b1 := missinggo.LimitLen(b, ip.Length()-po, avail) n, err = r.t.readAt(b1, pos) if n != 0 { err = nil diff --git a/storage/wrappers.go b/storage/wrappers.go index b8ba050b5503cd1729bff7f35e9d9285ffbe6283..044a1f5aa53fd62de03e4cdeed76e14d1f4189f6 100644 --- a/storage/wrappers.go +++ b/storage/wrappers.go @@ -45,7 +45,7 @@ } if off+int64(len(b)) > p.mip.Length() { panic("write overflows piece") } - missinggo.LimitLen(&b, p.mip.Length()-off) + b = missinggo.LimitLen(b, p.mip.Length()-off) return p.PieceImpl.WriteAt(b, off) } @@ -58,7 +58,7 @@ if off >= p.mip.Length() { err = io.EOF return } - missinggo.LimitLen(&b, p.mip.Length()-off) + b = missinggo.LimitLen(b, p.mip.Length()-off) if len(b) == 0 { return }