From 31e9c176f6c5610b84ccc3c75c1e46c23a99fd02 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Fri, 28 Jul 2023 11:06:37 -0400 Subject: [PATCH] fix: Protect RenderBlank() and IsFinished() with the lock RenderBlank() calls render() which requires the mutex to be held. IsFinished accesses p.state, which also requires the mutex to be held --- progressbar.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/progressbar.go b/progressbar.go index 0463678..f8cdbee 100644 --- a/progressbar.go +++ b/progressbar.go @@ -456,6 +456,9 @@ func (p *ProgressBar) String() string { // RenderBlank renders the current bar state, you can use this to render a 0% state func (p *ProgressBar) RenderBlank() error { + p.lock.Lock() + defer p.lock.Unlock() + if p.config.invisible { return nil } @@ -628,6 +631,9 @@ func (p *ProgressBar) ChangeMax64(newMax int64) { // IsFinished returns true if progress bar is completed func (p *ProgressBar) IsFinished() bool { + p.lock.Lock() + defer p.lock.Unlock() + return p.state.finished }