Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cedar-policy-core/src/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ impl Value {
}

#[inline(always)]
fn stack_size_check() -> Result<()> {
pub(crate) fn stack_size_check() -> Result<()> {
// We assume there's enough space if we cannot determine it with `remaining_stack`
if stacker::remaining_stack().unwrap_or(REQUIRED_STACK_SPACE) < REQUIRED_STACK_SPACE {
return Err(EvaluationError::recursion_limit(None));
Expand Down
8 changes: 8 additions & 0 deletions cedar-policy-core/src/tpe/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::tpe::err::ExprToResidualError;
use crate::validator::types::Type;
use crate::{
ast::{self, BinaryOp, EntityUID, Expr, PartialValue, Set, Value, ValueKind, Var},
evaluator::stack_size_check,
extensions::Extensions,
};

Expand Down Expand Up @@ -60,6 +61,13 @@ impl Evaluator<'_> {
}
Residual::Partial { kind, ty: _ty } => kind,
};

// Guard against stack overflows (just like the concrete evaluator), given the recursive nature of interpret
match stack_size_check() {
Ok(_) => (),
Err(_) => return Residual::Error(ty),
}

match kind {
ResidualKind::Var(Var::Action) => Residual::Concrete {
value: self.request.action.clone().into(),
Expand Down
Loading