Fixed #9068 (crash on invalid code)

This commit is contained in:
Daniel Marjamäki 2019-03-26 19:57:32 +01:00
parent ce11778a20
commit c262aeffdd
2 changed files with 9 additions and 0 deletions

View File

@ -8993,6 +8993,14 @@ static const Token *findUnmatchedTernaryOp(const Token * const begin, const Toke
void Tokenizer::findGarbageCode() const
{
// initialization: = {
for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (!Token::simpleMatch(tok, "= {"))
continue;
if (Token::simpleMatch(tok->linkAt(1), "} ("))
syntaxError(tok->linkAt(1));
}
// Inside [] there can't be ; or various keywords
for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (tok->str() != "[")

View File

@ -1656,6 +1656,7 @@ private:
ASSERT_THROW(checkCode("void f(){x=0,return return''[]()}"), InternalError);
ASSERT_THROW(checkCode("void f(){x='0'++'0'(return)[];}"), InternalError); // #9063
ASSERT_THROW(checkCode("void f() { x= 'x' > typedef name5 | ( , ;){ } (); }"), InternalError); // #9067
ASSERT_THROW(checkCode("void f() { x= {}( ) ( 'x')[ ] (); }"), InternalError); // #9068
}
void enumTrailingComma() {