Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added a call limit setting to prevent crashes or timeouts #684

Merged
merged 6 commits into from
Aug 10, 2022
Merged
Changes from 1 commit
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
6 changes: 2 additions & 4 deletions pest/src/parser_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ static CALL_LIMIT: AtomicUsize = AtomicUsize::new(0);
///
/// # Arguments
///
/// * `limit` - The maximum call depth or the number of calls.
/// If 0, the call depth or the number of calls is unlimited.
/// * `finite_calls` - If `true`, the parser execution is limited to
/// a finite number of calls (based on `limit`).
/// * `limit` - The maximum number of calls. If None,
/// the number of calls is unlimited.
tomtau marked this conversation as resolved.
Show resolved Hide resolved
pub fn set_call_limit(limit: Option<NonZeroUsize>) {
CALL_LIMIT.store(limit.map(|f| f.get()).unwrap_or(0), Ordering::Relaxed);
}
Expand Down