Skip to content

Commit

Permalink
refactor(parser): Pull recursion limit out to variable
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Mar 18, 2024
1 parent eb86543 commit 7f81084
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/toml_edit/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ pub(crate) mod prelude {
current: usize,
}

const LIMIT: usize = 128;

#[cfg(not(feature = "unbounded"))]
impl RecursionCheck {
pub(crate) fn check_depth(depth: usize) -> Result<(), super::error::CustomError> {
if depth < 128 {
if depth < LIMIT {
Ok(())
} else {
Err(super::error::CustomError::RecursionLimitExceeded)
Expand All @@ -113,7 +115,7 @@ pub(crate) mod prelude {
input: &mut Input<'_>,
) -> Result<Self, winnow::error::ErrMode<ContextError>> {
self.current += 1;
if self.current < 128 {
if self.current < LIMIT {
Ok(self)
} else {
Err(winnow::error::ErrMode::from_external_error(
Expand Down

0 comments on commit 7f81084

Please sign in to comment.