Skip to content

Commit

Permalink
Merge pull request #32 from thaJeztah/prevent_npe
Browse files Browse the repository at this point in the history
fifo.Close(): prevent possible panic if fifo is nil
  • Loading branch information
dmcgowan authored Sep 15, 2021
2 parents 6cca7cf + 80cf87d commit 60d22e8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fifo.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ func (f *fifo) Write(b []byte) (int, error) {
// before open(2) has returned and fifo was never opened.
func (f *fifo) Close() (retErr error) {
for {
if f == nil {
return
}

select {
case <-f.closed:
f.handle.Close()
Expand Down

0 comments on commit 60d22e8

Please sign in to comment.