From a1cb1e1395c2e94d6b427213915c6d6ae5709d20 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 23 Mar 2026 22:27:08 +0200 Subject: Fix global variable in repl.go with mutex protection --- internal/repl/repl.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'internal') 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{ -- cgit v1.2.3