Skip to content

Commit ff799b5

Browse files
Fix #14740 Hang: createAst, daca package lomiri-location-service (#8551)
1 parent 2d6f23e commit ff799b5

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

lib/tokenlist.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ static void compileBinOp(Token *&tok, AST_state& state, void (*f)(Token *&tok, A
740740
binop->astOperand1(state.op.top());
741741
state.op.pop();
742742
}
743+
if (!state.op.empty() && state.op.top() == binop)
744+
throw InternalError(tok, "Syntax Error: Infinite loop when creating AST.", InternalError::AST);
743745
state.op.push(binop);
744746
}
745747

test/testgarbage.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,8 @@ class TestGarbage : public TestFixture {
13431343
"{ return return { | { - name3 1 enum != >= 1 >= ++ { name6 | ; ++}}}}}}}"), UNKNOWN_MACRO);
13441344
ASSERT_THROW_INTERNAL(checkCode("else return % name5 name2 - =name1 return enum | { - name3 1 enum != >= 1 >= ++ { { || "
13451345
"{ return return { | { - name3 1 enum != >= 1 >= ++ { { || ; ++}}}}}}}}"), UNKNOWN_MACRO);
1346+
1347+
ASSERT_THROW_INTERNAL(checkCode("f(*p, requires(x));"), AST); // #14740
13461348
}
13471349

13481350
void templateSimplifierCrashes() {

0 commit comments

Comments
 (0)