diff/apply.readCounter: check negative size
`rc.r.Read()` may return a negative `int` on an error when the reader is set to a custom content store implementation Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
4a0ddfa974
commit
39158629f7
@ -125,6 +125,8 @@ type readCounter struct {
|
|||||||
|
|
||||||
func (rc *readCounter) Read(p []byte) (n int, err error) {
|
func (rc *readCounter) Read(p []byte) (n int, err error) {
|
||||||
n, err = rc.r.Read(p)
|
n, err = rc.r.Read(p)
|
||||||
rc.c += int64(n)
|
if n > 0 {
|
||||||
|
rc.c += int64(n)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user