Skip to content

Commit

Permalink
Thread-safety fix for unprotected mutation of decorator set. (#622)
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>

Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
Co-authored-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
  • Loading branch information
TristonianJones and inteon authored Jan 5, 2023
1 parent 11b2ffc commit de81e02
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 de81e02

Please sign in to comment.