From 2b708b6690f5e511290c14f59958929ac2b52891 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 11 Nov 2022 11:33:08 +0100 Subject: [PATCH] Fix concurrency problem in Board.buildConfigOptionsStructures --- arduino/cores/board.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arduino/cores/board.go b/arduino/cores/board.go index c5cd73daafd..a59c6d31d16 100644 --- a/arduino/cores/board.go +++ b/arduino/cores/board.go @@ -18,6 +18,7 @@ package cores import ( "fmt" "strings" + "sync" "github.com/arduino/go-properties-orderedmap" ) @@ -27,6 +28,7 @@ type Board struct { BoardID string Properties *properties.Map `json:"-"` PlatformRelease *PlatformRelease `json:"-"` + configOptionsMux sync.Mutex configOptions *properties.Map configOptionValues map[string]*properties.Map configOptionProperties map[string]*properties.Map @@ -69,6 +71,8 @@ func (b *Board) String() string { } func (b *Board) buildConfigOptionsStructures() { + b.configOptionsMux.Lock() + defer b.configOptionsMux.Unlock() if b.configOptions != nil { return }