diff --git a/src/archive/tar/reader.go b/src/archive/tar/reader.go index e9a6aa350aa2b2..67db71540c508e 100644 --- a/src/archive/tar/reader.go +++ b/src/archive/tar/reader.go @@ -763,9 +763,13 @@ func (tr *Reader) numBytes() int64 { // It returns 0, io.EOF when it reaches the end of that entry, // until Next is called to advance to the next entry. func (tr *Reader) Read(b []byte) (n int, err error) { + if tr.err != nil { + return 0, tr.err + } if tr.curr == nil { return 0, io.EOF } + n, err = tr.curr.Read(b) if err != nil && err != io.EOF { tr.err = err