Skip to content

Commit

Permalink
Merge pull request #703 from epage/overflow
Browse files Browse the repository at this point in the history
fix(parser): Don't stackoverflow on opt-level=0
  • Loading branch information
epage authored Mar 18, 2024
2 parents eb86543 + 6987f77 commit 487768d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,3 @@ include = [

[profile.release]
debug = 1

[profile.dev]
opt-level = 1
7 changes: 5 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,13 @@ pub(crate) mod prelude {
current: usize,
}

#[cfg(not(feature = "unbounded"))]
const LIMIT: usize = 100;

#[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 +116,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 487768d

Please sign in to comment.