Skip to content

Commit 10fe82a

Browse files
author
Tomas Tauber
committed
fix: not clear queue when exceeding a call limit
closes pest-parser#686 this logic sneaked in from the previous call depth checking; the follow up for the grammar timeout issue is pest-parser#685
1 parent 9c42f12 commit 10fe82a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f={f{/*/*6/*6/*6/*5/*6*6/*6/*6/*5/*7//*

meta/src/parser.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,10 @@ mod tests {
15181518
env!("CARGO_MANIFEST_DIR"),
15191519
"/resources/test/fuzzsample3.grammar"
15201520
));
1521+
let sample4 = include_str!(concat!(
1522+
env!("CARGO_MANIFEST_DIR"),
1523+
"/resources/test/fuzzsample4.grammar"
1524+
));
15211525
const ERROR: &str = "call limit reached";
15221526
pest::set_call_limit(Some(25_000usize.try_into().unwrap()));
15231527
let s1 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample1);
@@ -1529,5 +1533,8 @@ mod tests {
15291533
let s3 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample3);
15301534
assert!(s3.is_err());
15311535
assert_eq!(s3.unwrap_err().variant.message(), ERROR);
1536+
let s4 = crate::parser::parse(crate::parser::Rule::grammar_rules, sample4);
1537+
assert!(s4.is_err());
1538+
assert_eq!(s4.unwrap_err().variant.message(), ERROR);
15321539
}
15331540
}

pest/src/parser_state.rs

-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ impl<'i, R: RuleType> ParserState<'i, R> {
228228
#[inline]
229229
fn inc_call_check_limit(mut self: Box<Self>) -> ParseResult<Box<Self>> {
230230
if self.call_tracker.limit_reached() {
231-
self.queue.clear();
232231
return Err(self);
233232
}
234233
self.call_tracker.increment_depth();

0 commit comments

Comments
 (0)