mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Guarantee recursion_depth is never higher than recursion_limit
This commit is contained in:
@@ -479,7 +479,7 @@ mod sys {
|
||||
})?;
|
||||
let recursion_depth = vm.current_recursion_depth();
|
||||
|
||||
if recursion_limit > recursion_depth + 1 {
|
||||
if recursion_limit > recursion_depth {
|
||||
vm.recursion_limit.set(recursion_limit);
|
||||
Ok(())
|
||||
} else {
|
||||
|
||||
@@ -538,8 +538,9 @@ impl VirtualMachine {
|
||||
self.with_frame(frame, |f| f.run(self))
|
||||
}
|
||||
|
||||
// To be called right before raising the recursion depth.
|
||||
fn check_recursive_call(&self, _where: &str) -> PyResult<()> {
|
||||
if self.recursion_depth.get() > self.recursion_limit.get() {
|
||||
if self.recursion_depth.get() >= self.recursion_limit.get() {
|
||||
Err(self.new_recursion_error(format!("maximum recursion depth exceeded {}", _where)))
|
||||
} else {
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user