diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-23 22:27:08 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-23 22:27:08 +0200 |
| commit | a1cb1e1395c2e94d6b427213915c6d6ae5709d20 (patch) | |
| tree | c2dc0a2a70ca16717c60d265a7ae28d153101956 /internal/repl/repl.go | |
| parent | ec875dac170702fc7b8842bca8b2085e447a266d (diff) | |
Fix global variable in repl.go with mutex protection
Diffstat (limited to 'internal/repl/repl.go')
| -rw-r--r-- | internal/repl/repl.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/internal/repl/repl.go b/internal/repl/repl.go index 0234e49..1b6e249 100644 --- a/internal/repl/repl.go +++ b/internal/repl/repl.go @@ -7,6 +7,7 @@ import ( "os/signal" "path/filepath" "strings" + "sync" "syscall" "codeberg.org/snonux/perc/internal/calculator" @@ -25,9 +26,12 @@ type RPNState struct { } // getRPNState returns or creates the RPN state +var rpnStateMu sync.RWMutex var rpnState *RPNState func getRPNState() *RPNState { + rpnStateMu.Lock() + defer rpnStateMu.Unlock() if rpnState == nil { vars := rpn.NewVariables() rpnState = &RPNState{ |
