Skip to content

Commit

Permalink
Thread-safety fix for unprotected mutation of decorator set. (#621)
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <[email protected]>

Signed-off-by: Tim Ramlot <[email protected]>
Co-authored-by: Tim Ramlot <[email protected]>
  • Loading branch information
TristonianJones and inteon authored Jan 5, 2023
1 parent 6efb4a8 commit 1ad0c88
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cel/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ func newProgram(e *Env, ast *Ast, opts []ProgramOption) (Program, error) {
factory := func(state interpreter.EvalState, costTracker *interpreter.CostTracker) (Program, error) {
costTracker.Estimator = p.callCostEstimator
costTracker.Limit = p.costLimit
decs := decorators
// Limit capacity to guarantee a reallocation when calling 'append(decs, ...)' below. This
// prevents the underlying memory from being shared between factory function calls causing
// undesired mutations.
decs := decorators[:len(decorators):len(decorators)]
var observers []interpreter.EvalObserver

if p.evalOpts&(OptExhaustiveEval|OptTrackState) != 0 {
Expand Down

0 comments on commit 1ad0c88

Please sign in to comment.