Commit 4ea6e47c by Dino Radakovic Committed by Copybara-Service

`demangle`: Add complexity guard to `ParseQRequiresExpr`

This function copies the parser's state onto the stack in order to perform backtracking.
Adding a complexity guard will ensure that it fails gracefully, instead of contributing to excessive consumption of stack space.

PiperOrigin-RevId: 606720511
Change-Id: I2f6f03e5f8bc4cc571a4159ecfc2af6f3e00fa68
parent 34604d5b
...@@ -1942,6 +1942,8 @@ static bool ParseExprCastValue(State *state) { ...@@ -1942,6 +1942,8 @@ static bool ParseExprCastValue(State *state) {
// template <typename T> // template <typename T>
// int foo(T); // int foo(T);
static bool ParseQRequiresClauseExpr(State *state) { static bool ParseQRequiresClauseExpr(State *state) {
ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false;
ParseState copy = state->parse_state; ParseState copy = state->parse_state;
DisableAppend(state); DisableAppend(state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment