Skip to content

Commit

Permalink
Fix data race with struct access after calling Stop()
Browse files Browse the repository at this point in the history
We need to obtain a lock before accessing `s.active` because `Stop()`
might write to it at the same time.
  • Loading branch information
mislav committed Apr 23, 2020
1 parent bf6cf7a commit 506d399
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spinner.go
Expand Up @@ -285,10 +285,11 @@ func (s *Spinner) Start() {
case <-s.stopChan:
return
default:
s.mu.Lock()
if !s.active {
s.mu.Unlock()
return
}
s.mu.Lock()
s.erase()

if s.PreUpdate != nil {
Expand Down

0 comments on commit 506d399

Please sign in to comment.