Skip to content

Commit

Permalink
Merge pull request #156 from imsodin/fseventsPanic
Browse files Browse the repository at this point in the history
fsevents: Prevent nil deref
  • Loading branch information
rjeczalik authored Jun 26, 2018
2 parents f7ce7f7 + 2928bd1 commit 52ae50d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion watcher_fsevents_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func gostream(_, info uintptr, n C.size_t, paths, flags, ids uintptr) {
if n == 0 {
return
}
fn := streamFuncs.get(info)
if fn == nil {
return
}
ev := make([]FSEvent, 0, int(n))
for i := uintptr(0); i < uintptr(n); i++ {
switch flags := *(*uint32)(unsafe.Pointer((flags + i*offflag))); {
Expand All @@ -104,7 +108,7 @@ func gostream(_, info uintptr, n C.size_t, paths, flags, ids uintptr) {
}

}
streamFuncs.get(info)(ev)
fn(ev)
}

// StreamFunc is a callback called when stream receives file events.
Expand Down

0 comments on commit 52ae50d

Please sign in to comment.