Skip to content

Commit

Permalink
Fix read-after-eof panic (#6)
Browse files Browse the repository at this point in the history
Fixed a panic that was caused when Read() was called after a previous Read() returned io.EOF
  • Loading branch information
srmish-jfrog authored Dec 5, 2023
1 parent a335f45 commit 1b22259
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xfs/xfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ func (f *File) Stat() (fs.FileInfo, error) {
}

func (f *File) Read(buf []byte) (int, error) {
if f.buffer == nil {
return 0, io.EOF
}
if f.buffer.Len() == 0 {
f.currentBlock++
if f.currentBlock*f.blockSize >= f.Size() {
Expand Down

0 comments on commit 1b22259

Please sign in to comment.