From 875eeac72352b5d3c8ed640de8a456f73f835f6e Mon Sep 17 00:00:00 2001 From: Patrick Fairbank Date: Fri, 5 Oct 2018 00:43:30 -0700 Subject: [PATCH] Copy foul list when populating descriptions, to avoid persisting them with the result. --- field/arena_notifiers.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/field/arena_notifiers.go b/field/arena_notifiers.go index 4f03d3e..82ff026 100644 --- a/field/arena_notifiers.go +++ b/field/arena_notifiers.go @@ -248,13 +248,15 @@ func getAudienceAllianceScoreFields(allianceScore *RealtimeScore, allianceScoreS // Copy the description from the rules to the fouls so that they are available to the announcer. func populateFoulDescriptions(fouls []game.Foul) []game.Foul { - for i := range fouls { + foulsCopy := make([]game.Foul, len(fouls)) + copy(foulsCopy, fouls) + for i := range foulsCopy { for _, rule := range game.Rules { - if fouls[i].RuleNumber == rule.RuleNumber { - fouls[i].Description = rule.Description + if foulsCopy[i].RuleNumber == rule.RuleNumber { + foulsCopy[i].Description = rule.Description break } } } - return fouls + return foulsCopy }