Skip to content

Commit 487768d

Browse files
authored
Merge pull request #703 from epage/overflow
fix(parser): Don't stackoverflow on opt-level=0
2 parents eb86543 + 6987f77 commit 487768d

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,3 @@ include = [
2222

2323
[profile.release]
2424
debug = 1
25-
26-
[profile.dev]
27-
opt-level = 1

crates/toml_edit/src/parser/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ pub(crate) mod prelude {
9898
current: usize,
9999
}
100100

101+
#[cfg(not(feature = "unbounded"))]
102+
const LIMIT: usize = 100;
103+
101104
#[cfg(not(feature = "unbounded"))]
102105
impl RecursionCheck {
103106
pub(crate) fn check_depth(depth: usize) -> Result<(), super::error::CustomError> {
104-
if depth < 128 {
107+
if depth < LIMIT {
105108
Ok(())
106109
} else {
107110
Err(super::error::CustomError::RecursionLimitExceeded)
@@ -113,7 +116,7 @@ pub(crate) mod prelude {
113116
input: &mut Input<'_>,
114117
) -> Result<Self, winnow::error::ErrMode<ContextError>> {
115118
self.current += 1;
116-
if self.current < 128 {
119+
if self.current < LIMIT {
117120
Ok(self)
118121
} else {
119122
Err(winnow::error::ErrMode::from_external_error(

0 commit comments

Comments
 (0)