missinggo.LimitLen changed

This commit is contained in:
Matt Joiner 2017-12-03 13:44:08 +11:00
parent fa7c2e2bc6
commit b9a1cb5b8b
2 changed files with 3 additions and 4 deletions

View File

@ -193,11 +193,10 @@ func (r *Reader) readOnceAt(b []byte, pos int64, ctxErr *error) (n int, err erro
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

View File

@ -45,7 +45,7 @@ func (p Piece) WriteAt(b []byte, off int64) (n int, err error) {
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 @@ func (p Piece) ReadAt(b []byte, off int64) (n int, err error) {
err = io.EOF
return
}
missinggo.LimitLen(&b, p.mip.Length()-off)
b = missinggo.LimitLen(b, p.mip.Length()-off)
if len(b) == 0 {
return
}