grammar: limit recursion depth to prevent stack overflow (#29495) (#29755)

This commit is contained in:
Hrushikesh Ramilla authored and GitHub committed 2026-10-25 12:10:10 +01:00
1 parent fa3645feb5
commit f1168ac417
3 files changed
+29 -7

No files matched your search

+14
View File
@@ -165,6 +165,20 @@ int main()
root ::= "a"{5000,6000}
)""");
// Recursion depth limit exceeded (Issue #29495)
{
std::string deep_grammar = "root ::= ";
int n_depth = 300;
for (int i = 0; i < n_depth; ++i) {
deep_grammar += "(";
}
deep_grammar += "\"x\"";
for (int i = 0; i < n_depth; ++i) {
deep_grammar += ")";
}
verify_failure(deep_grammar.c_str());
}
verify_parsing(R"""(
root ::= "a"{0,5000}
)""", {