Skip to content

Commit

Permalink
Mutex protect buffer access in standard renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Mar 13, 2021
1 parent ac28669 commit a72db29
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions standard_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ func (r *standardRenderer) listen() {

// flush renders the buffer.
func (r *standardRenderer) flush() {
r.mtx.Lock()
defer r.mtx.Unlock()

if r.buf.Len() == 0 || r.buf.String() == r.lastRender {
// Nothing to do
return
}

out := new(bytes.Buffer)

r.mtx.Lock()
defer r.mtx.Unlock()

// Clear any lines we painted in the last render.
if r.linesRendered > 0 {
for i := r.linesRendered - 1; i > 0; i-- {
Expand Down

0 comments on commit a72db29

Please sign in to comment.