Skip to content

Commit

Permalink
remove package-global argValues array
Browse files Browse the repository at this point in the history
prevents data races in concurrent use
  • Loading branch information
sauerbraten committed Sep 22, 2020
1 parent e9e5e63 commit 0e59615
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0e59615

Please sign in to comment.