Skip to content

Commit 1b22259

Browse files
authored
Fix read-after-eof panic (#6)
Fixed a panic that was caused when Read() was called after a previous Read() returned io.EOF
1 parent a335f45 commit 1b22259

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

xfs/xfs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ func (f *File) Stat() (fs.FileInfo, error) {
458458
}
459459

460460
func (f *File) Read(buf []byte) (int, error) {
461+
if f.buffer == nil {
462+
return 0, io.EOF
463+
}
461464
if f.buffer.Len() == 0 {
462465
f.currentBlock++
463466
if f.currentBlock*f.blockSize >= f.Size() {

0 commit comments

Comments
 (0)