Skip to content

Commit f5db6e0

Browse files
committed
Bump parser step limit a little
1 parent 7d6fcbc commit f5db6e0

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/parser/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ doctest = false
1111

1212
[dependencies]
1313
drop_bomb = "0.1.4"
14+
15+
limit = { path = "../limit", version = "0.0.0" }

crates/parser/src/parser.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::cell::Cell;
44

55
use drop_bomb::DropBomb;
6+
use limit::Limit;
67

78
use crate::{
89
event::Event,
@@ -26,6 +27,8 @@ pub(crate) struct Parser<'t> {
2627
steps: Cell<u32>,
2728
}
2829

30+
static PARSER_STEP_LIMIT: Limit = Limit::new(15_000_000);
31+
2932
impl<'t> Parser<'t> {
3033
pub(super) fn new(token_source: &'t mut dyn TokenSource) -> Parser<'t> {
3134
Parser { token_source, events: Vec::new(), steps: Cell::new(0) }
@@ -48,7 +51,7 @@ impl<'t> Parser<'t> {
4851
assert!(n <= 3);
4952

5053
let steps = self.steps.get();
51-
assert!(steps <= 10_000_000, "the parser seems stuck");
54+
assert!(PARSER_STEP_LIMIT.check(steps as usize).is_ok(), "the parser seems stuck");
5255
self.steps.set(steps + 1);
5356

5457
self.token_source.lookahead_nth(n).kind

0 commit comments

Comments
 (0)