From af1f97dbf5a40740e26eb4f705a0bd744744807b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 18 Mar 2024 10:31:00 -0500 Subject: [PATCH 1/3] refactor(parser): Pull recursion limit out to variable --- crates/toml_edit/src/parser/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/toml_edit/src/parser/mod.rs b/crates/toml_edit/src/parser/mod.rs index eda3bc54..70e372c8 100644 --- a/crates/toml_edit/src/parser/mod.rs +++ b/crates/toml_edit/src/parser/mod.rs @@ -98,10 +98,13 @@ pub(crate) mod prelude { current: usize, } + #[cfg(not(feature = "unbounded"))] + 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) @@ -113,7 +116,7 @@ pub(crate) mod prelude { input: &mut Input<'_>, ) -> Result> { self.current += 1; - if self.current < 128 { + if self.current < LIMIT { Ok(self) } else { Err(winnow::error::ErrMode::from_external_error( From 21f545d05ca57560485f24cbf78aaf8478a52c5d Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 18 Mar 2024 10:32:28 -0500 Subject: [PATCH 2/3] fix(parser): Don't stackoverflow on opt-level=0 Fixes #702 --- crates/toml_edit/src/parser/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/toml_edit/src/parser/mod.rs b/crates/toml_edit/src/parser/mod.rs index 70e372c8..f1bbc56a 100644 --- a/crates/toml_edit/src/parser/mod.rs +++ b/crates/toml_edit/src/parser/mod.rs @@ -99,7 +99,7 @@ pub(crate) mod prelude { } #[cfg(not(feature = "unbounded"))] - const LIMIT: usize = 128; + const LIMIT: usize = 100; #[cfg(not(feature = "unbounded"))] impl RecursionCheck { From 6987f77649aacc7a6cc2b9cff0d1f22c260f9643 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 18 Mar 2024 10:29:34 -0500 Subject: [PATCH 3/3] chore(ci): Run with default opt-level --- Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c0ec6484..3487dcd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,3 @@ include = [ [profile.release] debug = 1 - -[profile.dev] -opt-level = 1