From d9f056da6283a594538f18de1d603a19bb484d0e Mon Sep 17 00:00:00 2001 From: sauerbraten Date: Tue, 22 Sep 2020 14:21:12 +0200 Subject: [PATCH] remove package-global argValues array prevents data races in concurrent use --- eval.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eval.go b/eval.go index f81748b..f6e96e9 100644 --- a/eval.go +++ b/eval.go @@ -1258,8 +1258,6 @@ func (st *Runtime) evalPipelineExpression(node *PipeNode) (value reflect.Value, return } -var argValues = [24]reflect.Value{} - func (st *Runtime) evaluateArgs(fnType reflect.Type, args CallArgs, pipedArg *reflect.Value) ([]reflect.Value, error) { numArgs := len(args.Exprs) if !args.HasPipeSlot && pipedArg != nil { @@ -1278,6 +1276,7 @@ func (st *Runtime) evaluateArgs(fnType reflect.Type, args CallArgs, pipedArg *re } } + argValues := make([]reflect.Value, numArgs) slot := 0 // index in argument values (evaluated expressions combined with piped argument if applicable) if !args.HasPipeSlot && pipedArg != nil { @@ -1325,7 +1324,7 @@ func (st *Runtime) evaluateArgs(fnType reflect.Type, args CallArgs, pipedArg *re } } - return argValues[:slot], nil + return argValues, nil } func isUint(kind reflect.Kind) bool {